Results 1 to 13 of 13

Thread: want to know user agent when using VB6 webbrowser Control

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    want to know user agent when using VB6 webbrowser Control

    I want to use web browser control in a vb6 application. My question is how requesting server will understand all request from this control? As internet explorer?

    means, is there a way for website to now that this website is being access by webbrowser control and not by a proper browser like firefox or chrome.

  2. #2
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: want to know user agent when using VB6 webbrowser Control

    Pointing both Windows Internet Explorer and a VB6-hosted WebBrowser control to http://www.useragentstring.com/ yielded nearly identical user agent strings on my system (the only difference was that the WebBrowser control was detected as being in Compatibility View mode). That means websites should not be able to tell the difference between Internet Explorer and the WebBrowser control based on the user agent string alone. You can temporarily override the default user agent, however, if you wish to be identified as something else. Simply specify the new user agent when you invoke the WebBrowser control's Navigate method:

    Code:
    WebBrowser1.Navigate "http://www.useragentstring.com/", Headers:="User-Agent: Visual Basic 6.0" & vbCrLf
    See Understanding the user-agent string for more info.
    Last edited by Bonnie West; Jan 15th, 2015 at 10:24 AM.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: want to know user agent when using VB6 webbrowser Control

    hi bonnie
    thanks for the tip
    but what if we click on some ajax links or submit some forms in our web browser control?

    then what headers server will consider?

    is there a way that server consider all requests with the headers i want?

  4. #4
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: want to know user agent when using VB6 webbrowser Control

    Quote Originally Posted by chunk View Post
    but what if we click on some ajax links or submit some forms in our web browser control?

    then what headers server will consider?
    Unfortunately, the user agent will revert to the default WebBrowser control user agent (which is almost the same as that of IE's). Like I said, the Navigate method can only temporarily override the default user agent. I've seen some workarounds for this, but I couldn't get them to successfully work here.

    Quote Originally Posted by chunk View Post
    is there a way that server consider all requests with the headers i want?
    Sorry, but I'm not aware of any solution for that. I must admit I haven't done enough research regarding that subject yet.
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: want to know user agent when using VB6 webbrowser Control

    no problem bonnie,
    but if you have any tip for me please share with me. As im facing a problem just because of this header situations

  6. #6
    Default Member Bonnie West's Avatar
    Join Date
    Jun 2012
    Location
    InIDE
    Posts
    4,057

    Re: want to know user agent when using VB6 webbrowser Control

    Quote Originally Posted by chunk View Post
    but if you have any tip for me please share with me.
    I suggest that you do a search on MSDN. You might find something that I've missed. Good luck!
    On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
    Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)

  7. #7
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,954

    Re: want to know user agent when using VB6 webbrowser Control

    w/o knowing specifically what issues you are having with it, I wonder if it's due to the webbrowser control mimicking or representing itself as an older version of IE, rather than the latest that may actually be installed.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: want to know user agent when using VB6 webbrowser Control

    thanks bonnie, i will search but still you keep in mind if you get anything for me in your mind.

    Tech there is no design issue, the issue is i wanted to know that if i access any website through web browser control and login into my account and click on available dashboard links or button that perform ajax GET / POST then is there a way for requesting server to know that im using a vb6 app not a proper browser.

    this is actually my question and also if i can change User-Agent headers to my all request to the website / server when i click on links in website perform ajax or redirect to another URL within the web browser control

  9. #9
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,954

    Re: want to know user agent when using VB6 webbrowser Control

    As im facing a problem just because of this header situations
    there is no design issue, the issue is i wanted to know that if i access any website through web browser control and login into my account and click on available dashboard links or button that perform ajax GET / POST then is there a way for requesting server to know that im using a vb6 app not a proper browser.
    So is there an issue or not? As for when they can tell, if the site works, what difference does it make?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: want to know user agent when using VB6 webbrowser Control

    Quote Originally Posted by techgnome View Post
    So is there an issue or not? As for when they can tell, if the site works, what difference does it make?

    -tg
    Sorry for my bad explanation :-( i explain here again

    Suppose i open a website in web browser control and now once site is loaded in web browser control then click on some buttons or links available on this site and these clicks on links and button communicate with website and open another page or whatever it is used for.

    So my questions is, is there a way to SET my custom headers to each request that is sent to website using web browser control?


    for example if we navigate to a website then we can set headers with the following code but how to SET headers when some links or buttons are clicked on the website?

    Code:
    WebBrowser1.Navigate "http://www.useragentstring.com/", Headers:="User-Agent: Visual Basic 6.0" & vbCrLf

  11. #11
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: want to know user agent when using VB6 webbrowser Control

    The browser control has an event called BeforeNavigate2 which allows you to examine the URL before the page is loaded. Here you can grab the URL and add your header data then navigate to this new link. In this event you also have the choice to not allow navigating to this new link.
    Last edited by jmsrickland; Jan 17th, 2015 at 02:56 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  12. #12
    PowerPoster
    Join Date
    Feb 2006
    Posts
    21,437

    Re: want to know user agent when using VB6 webbrowser Control

    Why are you trying to trick the web server?

    Be aware that scrapebots are detected by other means such as patterns of activities. You can still end up getting your entire subnet banned by Google for example and banks, auction and game sites, etc. frown on this mightily as well.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2007
    Posts
    912

    Re: want to know user agent when using VB6 webbrowser Control

    Quote Originally Posted by dilettante View Post
    Why are you trying to trick the web server?

    Be aware that scrapebots are detected by other means such as patterns of activities. You can still end up getting your entire subnet banned by Google for example and banks, auction and game sites, etc. frown on this mightily as well.
    im not doing scraping, im doing only what im expected to do on website. nothing unethical but i just wanted to know if this is possible to change header from web browser control

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width