Jump to content

Getting info of a Webpage without opening it.


amakrkr
 Share

Recommended Posts

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
Link to comment
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)
Link to comment
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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...