davil Posted May 24, 2010 Share Posted May 24, 2010 Hi all, I'm having a problem retrieving some information from the Dell website. I want to write the PHP to go through a text file and grab down warranty info etc from the Dell website for each service tag, I can parse the list no problem but first I want to make sure I can get info down for just one machine, I can do it in my browser like so: IF YOU JUST WANT TO GET INFO FROM TAB1 [WARRANTY INFO], USE THIS (replace ABCDEFG with whatever service tag): http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=ABCDEFG&~wsf=tabs IF YOU JUST WANT TO GET INFO FROM TAB2 [ORIGINAL SYSTEM CONFIGURATION], USE THIS (replace ABCDEFG with whatever service tag): http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=ABCDEFG&~tab=2&~wsf=tabs but when I use curl.exe (I'm on Windows) it just gives me HTML of a page requesting the service tag again. As you will see in my code I tried spoofing my user agent, but with no luck. <?php // spoofing Useragent $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; $useragent="Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.9 (KHTML, like Gecko) Chrome/6.0.400.0 Safari/533.9"; $useragent="Mozilla/5.0 (Windows; U; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)"; //I've tried all of these strings, but to no avail $serial='abcdefg-replacewithyourownserialnumber'; $url="http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=$serial&~tab=2&~wsf=tabs"; $stringtosend="curl --user-agent \"$useragent\" -0 $url"; $txt=shell_exec($stringtosend); echo $txt; ?> also the reason I'm using curl.exe and not PHP's curl classes is because I'm behind a proxy and was able to use "proxifier" to re-route curl.exe requests but couldn't get PHP working the same way (tried php.exe , should I have tried apache.exe? ) anyway if anybody knows why the page would react differently to curl than it would in browser , any help is much appreciated. Thanks Link to comment https://forums.phpfreaks.com/topic/202743-using-curl-to-retrieve-information-from-dell-website-for-multiple-pcs/ Share on other sites More sharing options...
davil Posted June 8, 2010 Author Share Posted June 8, 2010 In the end I figured out the way to set the proxy before using PHP's proper curl, and it worked. sorry. The following code reads the info into a variable , $x $ch = curl_init("http://support.dell.com/support/topics/global.aspx/support/my_systems_info/details?c=us&l=en&s=gen&ServiceTag=$serial&~tab=2&~wsf=tabs"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_PROXY, "http://10.10.10.10:80"); // Where 10.10.10.10 is the proxy IP and 80 is the port curl_setopt($ch, CURLOPT_PROXYPORT, 80); // Dunno why port 80 is set twice, but I copied this code and it works great curl_setopt ($ch, CURLOPT_PROXYUSERPWD, "myusername:mypassword"); $x = curl_exec($ch); Link to comment https://forums.phpfreaks.com/topic/202743-using-curl-to-retrieve-information-from-dell-website-for-multiple-pcs/#findComment-1069361 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.