Skip to content

Instantly share code, notes, and snippets.

@takakabe
Created September 28, 2019 14:13
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 takakabe/a30a63647a42c06d990ae46489481f64 to your computer and use it in GitHub Desktop.
Save takakabe/a30a63647a42c06d990ae46489481f64 to your computer and use it in GitHub Desktop.
Python
import requests
import lxml.html
html = requests.get('https://www.kabegiwablog.com').text
root = lxml.html.fromstring(html)
max_blog_post_count = 15
for i in range(1,max_blog_post_count):
blog_post = root.xpath('/html/body/div[3]/div/div[2]/div/div/div/div/div[1]/section['+str(i)+']/div[1]/h1/a')
print(blog_post[0].text+'\n'+blog_post[0].attrib['href']+'\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment