Jump to content
Sign in to follow this  
Stev

Grabbing HTML

Recommended Posts

Stev

I need my script check for a word in the page.

The website is facebook and I need check the account name (ex: Joe Doe).

I'll use a var ($name = "Joe Doe") to compare it.

If the word is there, continue. If not exit.

I'm using Google Chrome, no IE :D

Share this post


Link to post
Share on other sites
Xenobiologist

_InetGetSource and then StringInStr or StringRegExp.

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites
Stev

_InetGetSource and then StringInStr or StringRegExp.

Mega

Hmm.. What about cookies ?

This need be logged to FB in oder to see the account name.

Share this post


Link to post
Share on other sites
Kate

Hmm.. What about cookies ?

This need be logged to FB in oder to see the account name.

Do you want the script to automate logging into FB as well? Or will a user already be logged into FB when the script runs?

Share this post


Link to post
Share on other sites
Stev

Do you want the script to automate logging into FB as well? Or will a user already be logged into FB when the script runs?

The script already login to FB.

I want to check the name to know if it's logged or something was wrong.

If I can see the right account name, it's logged.

If not something fail.

Share this post


Link to post
Share on other sites
Kate

The script already login to FB.

I want to check the name to know if it's logged or something was wrong.

If I can see the right account name, it's logged.

If not something fail.

Okay, then Xenobiologist's answer is your best bet. I checked and my name shows up in my FB home page source code when I successfully log in (it does not if I type in the wrong password. Use _InetGetSource to turn the page source code into a string and then use StringInStr or StringRegExp to search for your name.

Share this post


Link to post
Share on other sites
Stev

Okay, then Xenobiologist's answer is your best bet. I checked and my name shows up in my FB home page source code when I successfully log in (it does not if I type in the wrong password. Use _InetGetSource to turn the page source code into a string and then use StringInStr or StringRegExp to search for your name.

Okey, I have something done...

Global $name = "Joe Doe"

#include <INet.au3>
$source = ConsoleWrite(_INetGetSource('http://www.facebook.com'))
; $html = '<a href="http://www.facebook.com/profile.php?id=5360150392&amp;ref=name">Joe Doe</a>'

$regex = StringRegExp($source, "regex here", 1); need learn regex

If Not @error Then MsgBox(0, "Regex", "You are logged: " & $regex)

If @error Then
    MsgBox(0, "Regex", "No Logged")
    Exit
EndIf

Can you help me with regex ?

Share this post


Link to post
Share on other sites
Authenticity

$source = ConsoleWrite ; Now $source = amount of characters written to the console. ;]

You mean:

$source = _INetGetSource('http://www.facebook.com')
     ConsoleWrite($source & @LF)

One pattern or expression to the StringRegExp can be:

"(?i)<a.*?>\Q" & $name & "\E"

Not restrictive as:

'(?i)\Q<a href="http://www.facebook.com/profile.php?id=\E\d+&amp;ref=name">\Q' & $name & '\E</a>'

\Q..\E is so the RexExp engine relating the inner text as it's without any metacharacters, etc.. special meaning.

Edit: ...

Edited by Authenticity

Share this post


Link to post
Share on other sites
Stev

$source = ConsoleWrite ; Now $source = amount of characters written to the console. ;]

You mean:

$source = _INetGetSource('http://www.facebook.com')
     ConsoleWrite($source & @LF)

One pattern or expression to the StringRegExp can be:

"(?i)<a.*?>\Q" & $name & "\E"

Not restrictive as:

'(?i)\Q<a href="http://www.facebook.com/profile.php?id=\E\d+&amp;ref=name">\Q' & $name & '\E</a>'

\Q..\E is so the RexExp engine relating the inner text as it's without any metacharacters, etc.. special meaning.

Edit: ...

It's working fine!

Thanks :D

Global $name = "myname"

#include <INet.au3>
$source = _INetGetSource('http://www.facebook.com')
     ConsoleWrite($source & @LF)
     
;$html = '<a href="http://www.facebook.com/profile.php?id=5360150392&amp;ref=name">Joe Doe</a>'

$regex = StringRegExp($source, "(?i)<a.*?>\Q" & $name & "\E", 1)

If Not @error Then MsgBox(0, "Regex", "You are logged")

If @error Then
    MsgBox(0, "Regex", "No Logged")
    Exit
EndIf

I have tried the script now and I can't get logged.

This get the "index" source as not logged.

Is there any way to get the source as logged user ?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.