Sign in to follow this  
Followers 0
amakrkr

Getting info of a Webpage without opening it.

5 posts in this topic

Hi all,

i am trying to get some information of a Webpage without starting it in a browser.

I have found an example from trancexx and tried to reproduce what she did but failed.

Below is my code and webpage (with a form) which i want to interact with.

I think page doesnt even load since $hConnect gives me "0".

Any help would be nice!

Thank you for reading.

#include "WinHttp.au3"

Global $sICAOLocation = "XENA"

; Initialize and get session handle
Global $hOpen = _WinHttpOpen()

; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, "www.ajpes.si")

; Fill form on that page
Global $sRead = _WinHttpSimpleFormFill($hConnect, "eobjave/default.asp?s=48","name:izbiraForm","name:Firma",$sICAOLocation)

; Close connection handle
_WinHttpCloseHandle($hConnect)

; See what's returned

Global $aRead = StringRegExp($sRead, ">(.*?\v\Q" & $sICAOLocation & "\E.*?)\v+<", 3)
If @error Then
    MsgBox(48 + 262144, "Meh...", "Nothing!")
Else
    ConsoleWrite($aRead[0] & @CRLF)
    MsgBox(64 + 262144, "Done!", "Result for " & $sICAOLocation & ": " & @CRLF & $aRead[0])
EndIf

Share this post


Link to post
Share on other sites



Using

ConsoleWrite($sRead & @CRLF)
I am getting the source of a page. I think the problem is in your RegExp pattern. What part of the source are you trying to extract?

the closest thing to a match I can see is:

<a href="objava.asp?s=48&id=782454">XENA, svetovanje in intelektualne storitve, d.o.o.</a>

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hi,

thank you for fast responce.

What i am trying to do is filling up that part of the forum that says "Firma" and reading results.

Edited by amakrkr

Share this post


Link to post
Share on other sites

Your code does that for me, but the regexp isn't returning any matches because of the \v's in there.

Removing them returns an array with 4 matches:

#include "WinHttp.au3"
#include <array.au3>
Global $sICAOLocation = "XENA"

; Initialize and get session handle
Global $hOpen = _WinHttpOpen()

; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, "www.ajpes.si")

; Fill form on that page
Global $sRead = _WinHttpSimpleFormFill($hConnect, "eobjave/default.asp?s=48","name:izbiraForm","name:Firma",$sICAOLocation)

; Close connection handle
_WinHttpCloseHandle($hConnect)

; See what's returned

Global $aRead = StringRegExp($sRead, ">(.*?\Q" & $sICAOLocation & "\E.*?)+<", 3) ;removed \v from the pattern
If @error Then
    MsgBox(48 + 262144, "Meh...", "Nothing!")
Else
    ConsoleWrite($aRead[0] & @CRLF)
    MsgBox(64 + 262144, "Done!", "Result for " & $sICAOLocation & ": " & @CRLF & $aRead[0])
    _ArrayDisplay($aRead) ;added this to view the results.
EndIf

In this case you could also directly request the page you want by specifying the Firma name in the url like this:

#include <array.au3>
Global $sICAOLocation = "XENA"
Global $sRead = BinaryToString(InetRead("http://www.ajpes.si/eobjave/rezultati.asp?podrobno=0&id_skupina=48&Firma=" & $sICAOLocation))
Global $aRead = StringRegExp($sRead, ">(.*?\Q" & $sICAOLocation & "\E.*?)+<", 3)
_ArrayDisplay($aRead)

Share this post


Link to post
Share on other sites

Your code does that for me, but the regexp isn't returning any matches because of the \v's in there.

Removing them returns an array with 4 matches:

#include "WinHttp.au3"
#include <array.au3>
Global $sICAOLocation = "XENA"

; Initialize and get session handle
Global $hOpen = _WinHttpOpen()

; Get connection handle
Global $hConnect = _WinHttpConnect($hOpen, "www.ajpes.si")

; Fill form on that page
Global $sRead = _WinHttpSimpleFormFill($hConnect, "eobjave/default.asp?s=48","name:izbiraForm","name:Firma",$sICAOLocation)

; Close connection handle
_WinHttpCloseHandle($hConnect)

; See what's returned

Global $aRead = StringRegExp($sRead, ">(.*?\Q" & $sICAOLocation & "\E.*?)+<", 3) ;removed \v from the pattern
If @error Then
    MsgBox(48 + 262144, "Meh...", "Nothing!")
Else
    ConsoleWrite($aRead[0] & @CRLF)
    MsgBox(64 + 262144, "Done!", "Result for " & $sICAOLocation & ": " & @CRLF & $aRead[0])
    _ArrayDisplay($aRead) ;added this to view the results.
EndIf

In this case you could also directly request the page you want by specifying the Firma name in the url like this:

#include <array.au3>
Global $sICAOLocation = "XENA"
Global $sRead = BinaryToString(InetRead("http://www.ajpes.si/eobjave/rezultati.asp?podrobno=0&id_skupina=48&Firma=" & $sICAOLocation))
Global $aRead = StringRegExp($sRead, ">(.*?\Q" & $sICAOLocation & "\E.*?)+<", 3)
_ArrayDisplay($aRead)

Hello again,

i cant tank you enuf for solving this problem for me.

It works like i wanted now, so i can continue with making the script.

Again thank you!

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  
Followers 0