Skip to content

Instantly share code, notes, and snippets.

@Fanna1119
Created October 6, 2018 08:06
Show Gist options
  • Save Fanna1119/44bbaf1ef3065d637909dba0bc478ab0 to your computer and use it in GitHub Desktop.
Save Fanna1119/44bbaf1ef3065d637909dba0bc478ab0 to your computer and use it in GitHub Desktop.
scrape html without bloatiful soup
import http.client
from lxml import html
conn = http.client.HTTPSConnection("www.thesaurus.com")
conn.request("GET", "/browse/honesty")
r1 = conn.getresponse()
data1 = r1.read()
# print(data1)
# raw html
tree = html.fromstring(data1)
synonyms = tree.xpath('//a[@class="css-3kshty etbu2a31"]/text()')
print(synonyms)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment