Skip to content

Instantly share code, notes, and snippets.

@tocttou
Last active January 7, 2016 19:29
Show Gist options
  • Select an option

  • Save tocttou/b9a67ed556300d0f7737 to your computer and use it in GitHub Desktop.

Select an option

Save tocttou/b9a67ed556300d0f7737 to your computer and use it in GitHub Desktop.
import requests
from lxml.html import fromstring
from bottle import get, run, response, request
@get('/')
def title_parser():
response.content_type = 'application/json'
url = request.query['string']
r = requests.get(url)
tree = fromstring(r.content)
resp = {}
resp['title'] = tree.findtext('.//title')
return json.dumps(resp)
run(host='0.0.0.0', port=8051, debug=False)
@shubham99sharma99

Copy link
Copy Markdown

poster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment