Created
July 9, 2017 00:33
-
-
Save abloch/6f3cd8a70778e5538a4b062fcad1a493 to your computer and use it in GitHub Desktop.
msn scraping example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from lxml import html | |
import requests | |
# get alert info | |
url = 'https://www.msn.com/en-us/weather/weatheralerts/Beverly%20Hills,California,Unite%20d%20States/we-city?weadegreetype=F&day=1&ocid=ansmsnweather' | |
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 4.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2049.0 Safari/537.36'} | |
page = requests.get(url, headers) | |
tree = html.fromstring(page.content) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment