3

I have a bit of a dilemma that I really could use some help with please. You see I need to copy the data from a web page into a worksheet and am having some dilemma with the following code block using XML 6.0

Dim httpRequest As XMLHTTP

Set httpRequest = New XMLHTTP
httpRequest.Open "GET", URL, False
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.send ""

At this point I have a Data Object to catch the data. 99 out of 100 times everything works great. Unfortunately this particular URL string has a "#" in it and it keeps getting converted to "%23" so I keep getting the wonderful error 404. The # MUST be in the URL. There is no other address or way to get to it than to include the #.

Example:

http://www.thisaddress.com/MovingFoward/#/Facility94

converts to and tries to pull from

http://www.thisaddress.com/MovingFoward/%23/Facility94

How does one go about preventing any kind of string character conversion?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Hexber
  • 43
  • 2
  • How do you create the `URL`? – John Saunders Jul 21 '15 at 04:02
  • Is this some type of weird API? - The `#` in a URL is a Fragment; it only has meaning for an interactive browser - its not even sent to a web server in a regular GET/POST so its hard to see why the output would differ if its missing – Alex K. Jul 21 '15 at 09:49
  • You are right sir. It is part of an interactive page and real time updated. It doesn't matter where the # is. If it's part of a word it still gets converted. You could have something like "This#Phrase" and it will come out "This%23Phrase". @AlexK. When you click through options the address bar reflects the options you choose but still contains the #. Example: `http://www.thisaddress.com/MovingFoward/#/Facility94/LeftOver/Z/Down` If one manually pastes to the browser it works and navigates to the exact option. The URL variable is passing the string correctly. I wonder if it's in setRequestHead – Hexber Jul 21 '15 at 21:02
  • John - The URL isn't created by anything fancy. I'd like to in the future but for now it's just a simple, normal one piece string without any extra dynamics/variables to it. @JohnSaunders – Hexber Jul 21 '15 at 21:07
  • In that case, I don't believe it. Even in VB6, strings don't magically change. There's something else going on. For instance, maybe the server is redirecting sometimes to the bad URL. – John Saunders Jul 21 '15 at 21:10
  • 1
    Xmlhttp is not a browser so if the page uses JavaScript to do anything based on the hash you will need a different approach – Alex K. Jul 21 '15 at 21:15

0 Answers0