Last active
January 7, 2016 19:29
-
-
Save tocttou/b9a67ed556300d0f7737 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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
commented
Jan 7, 2016

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