Medic873 Posted March 10, 2014 Posted March 10, 2014 Okay, I have contacted this company and they have given me permission to scrape there website and I have been trying to write a simple script to scrape there website and store the information in excell but for some reason it always stops after the second one. I thought at first it was because there was no data on the second so I tried to build in a if @error function but nothing seems to be working for the ArinNumber put in 02988826 expandcollapse popup#include <IE.au3> #Include <ScreenCapture.au3> #include <Excel.au3> #include <array.au3> #Include <File.au3> #include <string.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <INet.au3> $ArinNumber = InputBox ("Start Number", "Enter the number you want to start on?"); $LoopAmount = InputBox ("Loop Count", "How many data points do you want?"); Local $oExcel = _ExcelBookNew() _ExcelWriteCell($oExcel, "Id", 1, 1) _ExcelWriteCell($oExcel, "Registration Date", 1, 2) _ExcelWriteCell($oExcel, "Company Name", 1, 3) _ExcelWriteCell($oExcel, "City", 1, 4) _ExcelWriteCell($oExcel, "Country", 1, 5) _ExcelWriteCell($oExcel, "Handle", 1, 6) _ExcelWriteCell($oExcel, "Postal Code", 1, 7) _ExcelWriteCell($oExcel, "Update Time", 1, 8) $i = 2; do $ArinData = _INetGetSource("http://whois.arin.net/rest/customer/C" & $ArinNumber); InetClose ($ArinData) if $ArinData = '0' Then $i = $i + 1; $ArinNumber = $ArinNumber + 1; else $RegistrationDate = _StringBetween ($ArinData, '<registrationDate>', '</registrationDate>');Pulls the date that this as # was registered $CompanyName = _StringBetween($ArinData, '<name>', '</name>');The name of the company $City = _StringBetween ($ArinData, '<city>', '</city>');Pulls the City name $Country = _StringBetween ($ArinData, '<name>', '</name>');Pulls the country $Handle = _StringBetween($ArinData, '<handle>', '</handle>');Pulls the handle number $PostalCode = _StringBetween($ArinData, '<postalCode>', '</postalCode>');Pulls the zip code $UpdateTime = _StringBetween($ArinData, '<updateDate>', '</updateDate>');Pulls the date and time that it was last updated _ExcelWriteCell($oExcel, $i, $i, 1);Adds the Id to the excell sheet _ExcelWriteCell($oExcel, $RegistrationDate[0], $i, 2);Adds the registration date to the excel File _ExcelWriteCell($oExcel, $CompanyName[1], $i, 3);Adds the company name to the excell File _ExcelWriteCell($oExcel, $City[0], $i, 4);Adds the city to the excell File _ExcelWriteCell($oExcel, $Country[0], $i, 5);Adds the country to the excell File _ExcelWriteCell($oExcel, $Handle[0], $i, 6);Adds the Handle to the excell File _ExcelWriteCell($oExcel, $PostalCode[0], $i, 7);Adds the postal code to the excel File _ExcelWriteCell($oExcel, $UpdateTime, $i, 8);Adds the last time the AS # was updated to the excel File $i = $i + 1;Adds on to keep the looping going $ArinNumber = $ArinNumber + 1;Adds one to the arin loop to keep it going endif Until $i = $LoopAmount
Medic873 Posted March 10, 2014 Author Posted March 10, 2014 Has anyone been able to find out why this wont run.
Danp2 Posted March 10, 2014 Posted March 10, 2014 No, because the code as provided doesn't run. Latest Webdriver UDF Release Webdriver Wiki FAQs
Moderators JLogan3o13 Posted March 10, 2014 Moderators Posted March 10, 2014 Medic, please do not bump your posts without waiting at least 24 hours. This forum is full of volunteers spread all over the globe. The person who can best answer your question may not be online right now "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
somdcomputerguy Posted March 11, 2014 Posted March 11, 2014 I have re-written the bit of code you provided. Here is the return - 2 - 2 2012-06-01T05:32:28-04:00 - 2 Apple - 2 Cupertino - 2 ITALY - 2 C02988826 - 2 95014 - 2 $i - 3 $ArinNumber - 3 - 3 C:\Users\preferred customer\ex0310a.au3 (28) : ==> Subscript used with non-Array variable.: ConsoleWrite($RegistrationDate[0] & " - " & $i & @CRLF) ConsoleWrite($RegistrationDate^ ERROR And here is the (re-written) code - expandcollapse popup#include <string.au3> #include <INet.au3> $ArinNumber = InputBox ("Start Number", "Enter the number you want to start on?"); $LoopAmount = InputBox ("Loop Count", "How many data points do you want?"); $i = 2; do $ArinData = _INetGetSource("http://whois.arin.net/rest/customer/C" & $ArinNumber); if $ArinData = '0' Then $i = $i + 1; $ArinNumber = $ArinNumber + 1; else $RegistrationDate = _StringBetween ($ArinData, '<registrationDate>', '</registrationDate>');Pulls the date that this as # was registered $CompanyName = _StringBetween($ArinData, '<name>', '</name>');The name of the company $City = _StringBetween ($ArinData, '<city>', '</city>');Pulls the City name $Country = _StringBetween ($ArinData, '<name>', '</name>');Pulls the country $Handle = _StringBetween($ArinData, '<handle>', '</handle>');Pulls the handle number $PostalCode = _StringBetween($ArinData, '<postalCode>', '</postalCode>');Pulls the zip code $UpdateTime = _StringBetween($ArinData, '<updateDate>', '</updateDate>');Pulls the date and time that it was last updated ConsoleWrite($i & " - " & $i & @CRLF) ConsoleWrite($RegistrationDate[0] & " - " & $i & @CRLF) ConsoleWrite($CompanyName[1] & " - " & $i & @CRLF) ConsoleWrite($City[0] & " - " & $i & @CRLF) ConsoleWrite($Country[0] & " - " & $i & @CRLF) ConsoleWrite($Handle[0] & " - " & $i & @CRLF) ConsoleWrite($PostalCode[0] & " - " & $i & @CRLF) ConsoleWrite($UpdateTime & " - " & $i & @CRLF) $i = $i + 1;Adds on to keep the looping going $ArinNumber = $ArinNumber + 1;Adds one to the arin loop to keep it going ConsoleWrite("$i - " & $i & @CRLF & "$ArinNumber - " & @CRLF) endif Until $i = $LoopAmount I'm crap at debugging someone else's code (sometime's even my own..) but perhaps this will help somebody else help you. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now