Skip to content

Instantly share code, notes, and snippets.

@abloch
Created July 9, 2017 00:33
Show Gist options
  • Save abloch/6f3cd8a70778e5538a4b062fcad1a493 to your computer and use it in GitHub Desktop.
Save abloch/6f3cd8a70778e5538a4b062fcad1a493 to your computer and use it in GitHub Desktop.
msn scraping example
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