none
WebClient Download String in English Instead of Spanish...... RRS feed

  • Question

  • Good day everyone!

    I have a piece of software that I've developed for a client who needs certain data collected from eBay. The program uses the WebClient class to collect the data from the English United States eBay site. 

    The problem is that his computer is somehow telling the program to translate the HTML that is collected in the WebClient class into Spanish since he is from Chile, but I need the page to be downloaded in English since we are trying to access the United States eBay site.

    Here is a page that we're trying to access:
    https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=%22dog+collar%22&_sacat=0

    Why is this page still coming back in Spanish in the WebClient's downloaded string? Is it his computer settings or can I get the WebClient to download it in English?

    Here is what my WebClient class is looking like to pull back this page's HTML:
    Try
                Dim wc As New Net.WebClient
                Dim URL As String = wc.DownloadString("https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=%22dog+collar%22&_sacat=0")
                Dim match As Match = regex.Match(URL)
                If match.Success Then
                    TextBox1.Text = match.Value
                End If
            Catch ex As Exception
    
         End Try

    I'd appreciate the support!

    Tuesday, July 24, 2018 7:22 PM

All replies

  • I would try

    Dim wc As New Net.WebClient
    wc.Headers.Add("Accept-Language", "en-US")
    Dim URL As String = wc.DownloadString("https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=%22dog+collar%22&_sacat=0")

    Supported culture list

    https://msdn.microsoft.com/en-us/library/hh441729.aspx?f=255&MSPPError=-2147217396


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites



    Tuesday, July 24, 2018 7:40 PM
    Moderator
  • I would try

    Dim wc As New Net.WebClient
    wc.Headers.Add("Accept-Language", "en")
    Dim URL As String = wc.DownloadString("https://www.ebay.com/sch/i.html?_from=R40&_trksid=m570.l1313&_nkw=%22dog+collar%22&_sacat=0")


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Hi Karen! Hope you've been doing well my friend, long time no see! Hey, this may be exactly what I was looking for - the missing secret property! LOL Thanks, I'll give it a try and report back to you! :-)

    Tuesday, July 24, 2018 7:42 PM
  • First, it is quite possible that the language is being determined by the source IP address.

    Second, this code violates your terms of use with the website:

    https://www.ebay.com/help/policies/member-behaviour-policies/user-agreement?id=4259

    "In connection with using or accessing the Services you will not:

    use any robot, spider, scraper, data mining tools, data gathering and extraction tools, or other automated means to access our Services for any purpose, except with the prior express permission of eBay;"

    If you want to create any kind of automated tool for interacting with the eBay site, you must use their developer tools and APIs:

    https://www.developer.ebay.com/


    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"


    Tuesday, July 24, 2018 8:45 PM
    Moderator
  • Sorry Karen, but this didn't quite resolve the issue. The problem was that my client's IP address was telling eBay to translate the page into Spanish. BLah! Thanks again though.  :-)
    Tuesday, July 24, 2018 10:08 PM
  • Sorry Karen, but this didn't quite resolve the issue. The problem was that my client's IP address was telling eBay to translate the page into Spanish. BLah! Thanks again though.  :-)

    As I said, the language is likely being inferred by the source IP address.  And it isn't "legal" to scrape eBay this way.  Use the developer API and you can likely specify the return language.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, July 25, 2018 2:39 AM
    Moderator