0

This works: HtmlPage page = (HtmlPage) browser.getPage("http://www.somewebsite.com/viewprofile.aspx?profile_id=107992814")

However if I put the URL in a variable like this:

String userPage = "http://www.somewebsite.com/" + profileAnchorLink.getHrefAttribute();

page = (HtmlPage) browser.getPage (userPage);

I get an error that starts off like this

Exception in thread "main" ======= EXCEPTION START ======== Exception class=[net.sourceforge.htmlunit.corejs.javascript.WrappedException] com.gargoylesoftware.htmlunit.ScriptException: Wrapped com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot read property "data" from undefined (https://www.gstatic.com/swiffy/v7.3.2/runtime.js#72)

Any ideas? I had an html web bot that worked beautifully but then I upgraded to Windows 10 and went through some messy problems, not sure if that has anything to do with it. I made a new project and re-imported the HtmlUnit libraries in case something was broken (kept the same workspace though not sure if that matters) and still to no avail.

The even weirder part is that sometimes it actually works. Initially my program wasn't even using the URL it was just going directly to the link but then something broke so I tried to do things a different way, the URL method was actually working but then it started to work only sometimes and now it doesn't work at all.

So I'm really quite lost on what's going on here.

Sentinel
  • 441
  • 1
  • 6
  • 25

1 Answers1

0

Seems like the real problem was that I wasn't using getPage properly, after implementing the information from this answer (How to call getPage from HtmlUnit WebClient and have setTimeout not wait forever?) all is well...for now.

Community
  • 1
  • 1
Sentinel
  • 441
  • 1
  • 6
  • 25