Skip to content

Instantly share code, notes, and snippets.

@averrin
Created October 1, 2015 10:06
Show Gist options
  • Save averrin/9416a682f80e96c78827 to your computer and use it in GitHub Desktop.
Save averrin/9416a682f80e96c78827 to your computer and use it in GitHub Desktop.
Fetch popular UAs
#!env python3
import requests
from lxml import html
page = requests.get('https://techblog.willshouse.com/2012/01/03/most-common-user-agents/')
page = html.fromstring(page.text)
path = '//*[@id="post-2229"]/div[2]/table/tbody'
table = page.xpath(path)[0]
for row in table[:10]:
ua = row[1].text_content()
browser = row[2].text_content()
print('%s: %s' % (browser, ua))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment