with some AutoIt code?
I have a bit of code that grabs a page source and puts it in a string.
For some reason, adding a variable onto the url to grab the source from is screwing up the thing that grabs the source.
When I comment out the variable and leave the part typed out and in quotation marks, it works fine.
If you need to see the code to help, PM me.
Results 1 to 7 of 7
Thread: Anyone feel like helping me
- 22 Sep. 2012 03:19am #1
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 764.00
Anyone feel like helping me
- 22 Sep. 2012 05:31am #2
Sure, post away.
- 22 Sep. 2012 07:00am #3
Post it. Not going to PM you.
- 22 Sep. 2012 04:11pm #4
What Artificial said. Too lazy to inspect your issue via PM. Just post here.
- 23 Sep. 2012 01:47am #5
- Join Date
- Apr. 2010
- Location
- When freedom is outlawed only outlaws will be free
- Posts
- 5,113
- Reputation
- 195
- LCash
- 2483.00
Code:#include <iNet.au3> $start = 1 $finish = 4 $404 = "404" For $lineNum = $start To $finish $fl = FileReadLine("links.txt", $lineNum) $url = "http://test.com//" & $fl &"/" $source = _INetGetSource($url) MsgBox(0, "lol", $source) FileOpen("links.txt") FileOpen("output.txt") FileWrite("output.txt", $url & @CRLF) If StringInStr($source, $404) Then MsgBox(0, "found", "found") Else MsgBox(0, "not found", "not found") EndIf Next MsgBox(0, "test", "done")
Also, most of the message boxes are just for testing purposes.
What it does:
1.) goes to the url http://test.com/(first line of your text document)
2.) Grabs the source
3.) Checks for the string "404" within the source
The writing to the output.txt is going to be an If statement later. If the string 404 wasn't found, save link. Else, move on to next link.
I can't get it to grab the source though x-x
When I delete the variable ending and just leave it at
"http://test.com/"
it works, but when I make it
"http://test.com/" & $variable
it just breaks x-x
Help? Also, test.com is obviously not the real URL I plan to use it with. The real URL I plan to keep secret until I release it. Feel free to swap it with any URL you like.
- 23 Sep. 2012 02:25am #6
Unsightly.
PHP Code:#include <INet.au3>
For $i = 1 To 4
$sURL = FileReadLine("links.txt", $i)
$sSource = _INetGetSource($sURL)
;FileWrite("output.txt", $sSource & @CRLF)
If StringInStr($sSource, "404") Then
;Failure
Else
;Success
EndIf
Next
ConsoleWrite("Done." & @CRLF)
Last edited by The Unintelligible; 23 Sep. 2012 at 05:28am.
- 23 Sep. 2012 02:30am #7
Note: Bare in mind that simply searching for the substring "404" isn't reliable to diagnosing whether the page was found or not as "404" is fairly generic enough to be in any given web page. To properly test if the page wasn't found, you're going to need to get the response headers somehow to view the status.
You could do this via an HTTP instance as opposed to the limited INet API functions provided in the standard library.