A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

Anyone feel like helping me

1.6k views · started by 323 ·
#1
Anyone feel like helping me
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.
#2
Sure, post away.
#3
Post it. Not going to PM you.
#4
What Artificial said. Too lazy to inspect your issue via PM. Just post here.
#5
#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")


I can't seem to be able to grab the source of the page.

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.
#6
Unsightly.

#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)
#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.