Sign in to follow this  
Followers 0
w0uter

_GetSource()

20 posts in this topic

#1 ·  Posted (edited)

;===============================================================================
;
; Function Name:    _INetGetSource()
; Description:    Gets the source from an URL without writing a temp file.
; Parameter(s):  $s_URL = The URL of the site.
; Requirement(s):   A beta version w/ COM
; Return Value(s):  On Success - Returns the source code.
;                  On Failure - 0  and sets @ERROR = 1
; Author(s):        KIX: Lonkero.
;                   BASE CONVERSION: SvenP.
;                   UDF: Wouter van Kesteren.
;
;===============================================================================

_INetGetSource.zip

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites



Sorry for being picky, but maybe you should rename it to "_URLGetSource" or "INetGetSource" or some such to keep up with the consistent namespace type things we have so far...

BTW,

Good work! :(


FootbaG

Share this post


Link to post
Share on other sites

This isn't necessarily a good idea..

If StringLeft($s_URL, 7) <> 'http://' Then $s_URL = 'http://' & $s_URL

What if they are using an https:// URL? This line will change the URL they sent to http://https://www.etc.com

Otherwise it works fine.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

thank you Saunders.

how do you like it like this ?

;add 'http://' if 'http(s)://' is not present
    If StringLeft($s_URL, 7) <> 'http://' AND StringLeft($s_URL, 8) <> 'https://' Then $s_URL = 'http://' & $s_URL

and yer link will end up @ paypal :(

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

Looks pretty good to me, but I was never good at finding problems in code... But from what I see, there are none :(


FootbaG

Share this post


Link to post
Share on other sites

after looking at it again. it noticed that it has no error handeling what so ever.

i was wondering, would it be possible to:

get the current autoit.error function.

change it to a new function.

detect if there is an error.

change it back to the old function.

(hope you catch my drift)


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

anyone ?

<{POST_SNAPBACK}>

I'd recommend for cross-platform / future version compatibility that you grab the appropriate winhttp.winhttprequest.5.1 method from the registry - This will prevent object not found errors.... While global variables are very bad, in a case like this I might use one, such that I'd put the regread in a if not defined structure, so that I didn't have to do a regread every time the func was called.

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

icould you explain it a bit more ?

<{POST_SNAPBACK}>

For portability, you [c|sh]ould check the registry keys that match the following,

and use the most desired version available... Your script will fail w/ a com error if

an older IE is being run.

HKEY_CLASSES_ROOT\WinHttp.WinHttpRequest.5


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

i have troubles with the errorhandling ....

if a url is not valid, like http://w.a i get an error:

Line 34...

$o_HTTP.send()

$0_HTTP.send()^ERROR

Error: The requested action with this object has failed.

Why i dont get the MsGBox with "...error" ?

$webadresse=_INetGetSource($sInputBoxAnswer)

Select

Case @ERROR = 0

Msgbox(0,"Url-Prüfung",$sInputBoxAnswer & "...ok")

Case @ERROR = 1

Msgbox(0,"Url-Prüfung",$sInputBoxAnswer & "...error")

EndSelect


das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

Share this post


Link to post
Share on other sites

since it is working with COM.

i am not able to check if the error occurs,

without adding a custom errorhandeler wich will overwrite the old one.

untill they change the objevent to return the old func in like a byref var.

there is not really much i can do about this.


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Share this post


Link to post
Share on other sites

since it is working with COM.

i am not able to check if the error occurs,

without adding a custom errorhandeler wich will overwrite the old one.

untill they change the objevent to return the old func in like a byref var.

there is not really much i can do about this.

<{POST_SNAPBACK}>

W0uter,

I have added an option to retrieve the current name of the COM Error Handler function, using ObjEvent.

However a running Error Handler can not be stopped, because it's too difficult to retrieve the variable it had been assigned to.

The modifications will be uploaded soon (need to rewrite the documentation first).

Regards,

-Sven

Share this post


Link to post
Share on other sites

I get Unknown function name.: on ObjCreate.

How do I determine what version I have, and is that the prob?

J


If I am too verbose, just say so. You don't need to run on and on.

Share this post


Link to post
Share on other sites

I get Unknown function name.: on ObjCreate.

How do I determine what version I have, and is that the prob?

J

<{POST_SNAPBACK}>

you need the latest beta version.

http://www.autoitscript.com/autoit3/files/beta/autoit/


My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

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