Skip to content

Instantly share code, notes, and snippets.

@echiesse
Created May 30, 2018 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save echiesse/14515731c76e4db72d5b84b3d0751a29 to your computer and use it in GitHub Desktop.
Save echiesse/14515731c76e4db72d5b84b3d0751a29 to your computer and use it in GitHub Desktop.
Scrapper example (scrapping https://observador.pt/seccao/desporto/)
import requests
from io import StringIO
from lxml import etree
URL = "https://observador.pt/seccao/desporto/"
def main():
response = requests.get(URL)
content = response.text
parser = etree.HTMLParser()
html = etree.parse(StringIO(content), parser)
body = html.xpath('body')[0]
titles = body.xpath(".//a[@class='obs-accent-color']")
for t in titles:
print(t.text)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment