jeudi 1 octobre 2015

Extract a word that follows a particular word from a webpage with python

I am writing a simple web scraper script to extract a single word from a web page. The word I require changes regularly, but comes after a word that never changes, so I can search for it.

This my script so far:

#!/bin/python

import requests
response = requests.get('http://ift.tt/1rRfaTs')
print(response.text)

Which obviously prints the whole HTML of the page. But the bit I need is the password:

<li>All bundles include UDP53, UDP 25000, TCP 80, TCP 443 profile</li>
<li>Username: <strong>vpnbook</strong></li>
<li>Password: <strong>binbd5ar</strong></li>
</ul>  

How could I print ONLY 'binbd5ar' (or whatever replaces it) to STOUT?




Aucun commentaire:

Enregistrer un commentaire