Scrapbook is simple scraping library.
from scrapbook import Element, Content
import requests
class Twitter(Content):
username = Element(
xpath='//*[@id="page-container"]/div[2]/div/div'
'/div[1]/div/div/div/div[1]/h2/a/span/b/text()',
)
screen_name = Element(
xpath='//*[@id="page-container"]/div[2]/div/div/'
'div[1]/div/div/div/div[1]/h1/a',
)
response = requests.get('https://twitter.com/odoku')
data = Twitter().parse(response.text)
print(data)
- Python 2.7 or Python 3.3+
pip install scrapbook