Sign in to follow this  
Followers 0
flownzu

_INetGetSource problem.

4 posts in this topic

Hi,

I'm currently working on a small project which I just started. A tool that should scan through the Steam Sales and tell me when a game on my wishlist is on sale (since Steam doesn't send me E-Mails when this is the case). Few minutes in I stumble across the first problem: I receive the source of the sales which is the first page of currently 4 (1 - 25 of 78). Now when I try to get the source of the 2nd page I just get the exact same one :(

I think this is because Steam loads the first page and after that updates it with the provided pagenumber. So how do I get the right source for the next pages?

Here is my current source code: http://pastebin.com/1zwPT11R

I hope that someone can help me :)

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <INet.au3>
#include <Array.au3>
#include <GuiListView.au3>

Global $PageNumber, $ParsedGames

AutoItSetOption("GUIOnEventMode", 1)
$Form1 = GUICreate("Steam Sales Watcher", 394, 449, 192, 124)
$Label1 = GUICtrlCreateLabel("Steam Community ID/custom URL: ", 8, 8, 172, 17)
$Input1 = GUICtrlCreateInput("", 184, 4, 121, 21)
$Button1 = GUICtrlCreateButton("Parse Wishlist", 312, 2, 75, 25)
$Checkbox1 = GUICtrlCreateCheckbox("Refresh Sales every", 8, 32, 121, 17)
$Input2 = GUICtrlCreateInput("", 132, 28, 49, 21)
$Label2 = GUICtrlCreateLabel("minutes.", 192, 32, 43, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Notify when Game on Wishlist is on sale.", 8, 56, 217, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Notify when Game is reduced by over", 8, 80, 201, 17)
$Input3 = GUICtrlCreateInput("", 216, 76, 41, 21)
$Label3 = GUICtrlCreateLabel("%.", 264, 80, 15, 17)
$ListView1 = GUICtrlCreateListView("Game|Source|Price|Reduction|Wishlist", 8, 104, 378, 334)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 179)
_GUICtrlListView_SetColumnWidth($ListView1, 1, 0)
_GUICtrlListView_SetColumnWidth($ListView1, 2, 65)
_GUICtrlListView_SetColumnWidth($ListView1, 3, 65)
_GUICtrlListView_SetColumnWidth($ListView1, 4, 65)
$Button2 = GUICtrlCreateButton("Refresh now", 312, 28, 75, 25)
GUICtrlSetOnEvent(-1, "RefreshSales")
GUISetOnEvent(-3, "_Exit", $Form1)
GUISetState(@SW_SHOW)

While Sleep(10)

WEnd

Func _Exit()

Exit

EndFunc   ;==>_Exit

Func RefreshSales()

$PageNumber = 1
$ParsedGames = 0
$Source = _INetGetSource("http://store.steampowered.com/search/?specials=1")

$Results = StringRegExp($Source, '<div class="search_pagination_left">(?s)\s+[[:alpha:]]+\s\d+\s\-\s\d+\s[[:alpha:]]+\s(\d+)', 1)

If IsArray($Results) Then $Results = $Results[0]

_GUICtrlListView_BeginUpdate($ListView1)

While $ParsedGames < $Results

$PageNumber += 1
ParseGames()

WEnd

_GUICtrlListView_EndUpdate($ListView1)

EndFunc   ;==>RefreshSales

Func ParseGames()

$Source = _INetGetSource("http://store.steampowered.com/search/?specials=1#sort_by=&sort_order=ASC&specials=1&page=" & $PageNumber)
ConsoleWrite($Source & @CRLF & "-----------------------------------------------------------------------------------------" & @CRLF)
$StoreLinks = StringRegExp($Source, '(?i)<a href="(http://store.steampowered.com/app/.*)"\sclass', 3)
$Prices = StringRegExp($Source, '(?i)<div class="col search_price"><span style="color: #888888;"><strike>(.*)&#8364; </strike></span><br>(.*)&', 3)
$GameNames = StringRegExp($Source, '(?i)<h4>(.*)</h4>', 3)

For $i = 0 To UBound($GameNames) - 1

$PriceReduction = 100 * (1 - Round(StringReplace(StringReplace($Prices[$i * 2 + 1], ",", "."), "-", "0") / StringReplace(StringReplace($Prices[$i * 2], ",", "."), "-", "0"), 2))
GUICtrlCreateListViewItem(StringReplace($GameNames[$i], "&trade;", "™") & "|" & "Steam|" & StringReplace(StringReplace($Prices[$i * 2 + 1], "-", "0"), ",", ".") & "|-" & $PriceReduction & "%|" & "No", $ListView1)
$ParsedGames += 1

Next

_GUICtrlListView_HideColumn($ListView1, 1)

EndFunc   ;==>ParseGames
You can post the script in the Forum, you would receive more help

After executing the script I receive the following error

C:\Script.au3 (79) : ==> Subscript used with non-Array variable.:
$PriceReduction = 100 * (1 - Round(StringReplace(StringReplace($Prices[$i * 2 + 1], ",", "."), "-", "0") / StringReplace(StringReplace($Prices[$i * 2], ",", "."), "-", "0"), 2))
$PriceReduction = 100 * (1 - Round(StringReplace(StringReplace($Prices^ ERROR
->07:42:02 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 48.939
Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Share this post


Link to post
Share on other sites

After executing the script I receive the following error

C:\Script.au3 (79) : ==> Subscript used with non-Array variable.:
$PriceReduction = 100 * (1 - Round(StringReplace(StringReplace($Prices[$i * 2 + 1], ",", "."), "-", "0") / StringReplace(StringReplace($Prices[$i * 2], ",", "."), "-", "0"), 2))
$PriceReduction = 100 * (1 - Round(StringReplace(StringReplace($Prices^ ERROR
->07:42:02 AutoIT3.exe ended.rc:1
>Exit code: 1   Time: 48.939

Hmmm that never happens to me. But you can just try getting the sources of the sales page with different page number. They are completely the same except from the current server timestamp.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Nah! According to the following script the returns are not the same

Local $aPage[3]

For $i = 0 To 2
$aPage[$i] = BinaryToString(InetRead("http://store.steampowered.com/search/?specials=1#sort_by=&sort_order=ASC&specials=1&page=" & $i))
FileWrite("Page" & $i + 1& ".txt", $aPage[$i])
Next


If $aPage[0] = $aPage[1] Then

ConsoleWrite("Page1 is equal to Page2" & @CRLF)

ElseIf $aPage[0] = $aPage[2] Then

ConsoleWrite("Page1 is equal to Page3" & @CRLF)

ElseIf $aPage[1] = $aPage[2] Then

ConsoleWrite("Page2 is equal to Page3" & @CRLF)

Else

ConsoleWrite("None are equal." & @CRLF)

EndIf

ShellExecute("Page1.txt")
ShellExecute("Page2.txt")
ShellExecute("Page3.txt")
Its different for each page. Try debugging your expressions by checking the error return and the calculations.

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

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