Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eachmatch returning empty array despite valid selector #11

Closed
sh34v3 opened this issue Feb 21, 2019 · 1 comment
Closed

eachmatch returning empty array despite valid selector #11

sh34v3 opened this issue Feb 21, 2019 · 1 comment

Comments

@sh34v3
Copy link

sh34v3 commented Feb 21, 2019

I am trying to scrape some weather data from weather underground. According to the documentation .class selectors should work right? Why I am still getting an empty HTMLNode array with the following code:

using Cascadia
using Gumbo
using HTTP

function getWindChill(speed::Int64)

    url = "https://www.wunderground.com/weather/us/ma/boston";

    #get and parse html
    res = HTTP.get(url);
    html = parsehtml(String(res.body));

    #select the html element from DOM using cascadia and eachmatch
    s = Selector(".wu-value wu-value-to")
    temp = eachmatch(s, html.root)

    temp

    #calculation for wind chill based on temperature and speed
end

getWindChill(10)

@aviks
Copy link
Collaborator

aviks commented Mar 18, 2020

multiple class names should be concatenated by dots, not spaces. So it should be s = Selector(".wu-value.wu-value-to")

julia>   s = Selector(".wu-value.wu-value-to");

julia>   temp = eachmatch(s, html.root);

julia> length(temp)
15

PS: it's very late for this issue, but placing it here for the record.

@aviks aviks closed this as completed Mar 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants