Consider opening a web session such as (Mathematica 11.3)
session = StartExternalSession["WebDriver-Chrome"];
ffoxdo[cmd_] := ExternalEvaluate[session, cmd];
Then we can navigate to a webpage, e.g.
ffoxdo[ "OpenWebPage" -> "https://weather.com/weather/tenday/l/New+York+NY+10017:4:US"];
After that the respective browser is showing a website. Now I would like to import the current content of that web browser as a data table into Mathematica. If I try
Import[session, "Data"]
the operation fails, which is not too surprising. I assume there is a special syntax for that? How should I do this properly?
PS:
The actual website I would like to get data from takes a second to load the relevant data into view, which is why I am trying to access it through a session instead of using Import[httplink]
(the data is missing if I do that).
EDIT:
While another question mentions a function that might lead to a solution "WebUnit`GetPageHtml", it does not solve the issue raised here per se. Making use of two more lines, we can load the html as
session = StartExternalSession["WebDriver-Chrome"];
ffoxdo[cmd_] := ExternalEvaluate[session, cmd];
iws = ExternalEvaluateWebDriver`Private`websession[];
ffoxdo[ "OpenWebPage" -> "https://weather.com/weather/tenday/l/New+York+NY+10017:4:US"];
html=WebUnit`GetPageHtml[iws];
DeleteObject[session];
However, the goal is to extract data from the html
code, similarly to what the output of
Import["https://weather.com/weather/tenday/l/New+York+NY+10017:4:US","Data"]
would give. Trying Import[html,"Data"]
leads to an error. How should I be doing this properly?
WebUnit`GetPageHtml
in this Q&A If that link does not answer your question, do let us know, otherwise probably you may not get an answer. $\endgroup$