Created
May 30, 2018 16:26
-
-
Save echiesse/14515731c76e4db72d5b84b3d0751a29 to your computer and use it in GitHub Desktop.
Scrapper example (scrapping https://observador.pt/seccao/desporto/)
This file contains 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
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