Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
What do I look for when wanting to scrape a certain thing?
-
import bs4, requests def get_beautiful_soup(url): return bs4.BeautifulSoup(requests.get(url).text) soup = get_beautiful_soup('http://www.weatherbug.com') print(soup.get_text())
Ok so as of now, in the script above I have made you use weather bug to find the weather in your local area, and your area and weather should appear at the top. After looking into the buetiful soup 4 documentation, I see that you are able to extract certain information. The way it is explained on the Documentation is that you can use "for link in soup.find_all('a'):" to find all of the "<a>" 's in the website. My problem is that every location has a different name, so I can't just tell it to look for one because that won't find your location. If you know what to do please help, I will continue to do research on this.
-
This is not really a pythonista-specific question, you might have more luck in stackoverflow. It's a far larger community, you'll likely get an answer within an hour.
-
Well there has to be someone in this community who knows how.
-
Weatherbug is not a simple site, it has lots of fancy CSS and JavaScript. For someone with your apparent skill level, don't try it. Use a pre-built Python library for weather forecasts, like this one which I found with a quick Google search. The
location
module can give you the device's latitude / longitude. -
If you download the previously linked library to
site_packages
, this code will get you the current weather at a location, as an exampleimport location, forecastio api_key = 'bb17c2f14b8e3e00d543485185af019c' location_data = location.get_location() lat = location_data['latitude'] lon = location_data['longitude'] forecast = forecastio.load_forecast(api_key, lat, lon) weather = forecast.currently() print weather.summary
Please get your own API key instead of continuing to use mine once you verify that it works. Read the documentation for
forecastio
for more complex uses. -
Ok, thanks a lot
-