Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import requests
- import BeautifulSoup
- def extract():
- resp = requests.get('http://subfusion.net/cgi-bin/quote.pl',
- params={'quote':'futurama', 'number':'1'})
- soup = BeautifulSoup.BeautifulSoup(resp.text)
- for ele in soup.html.body.findAll('b'):
- try:
- for tag in ele.findAll('br'):
- if isinstance(tag.next, BeautifulSoup.NavigableString):
- return tag.next.format()
- except:
- pass
- def main():
- try:
- repeat = int(sys.argv[1])
- except:
- repeat = 1
- for _ in range(repeat):
- print extract()
- print "-" * 75
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement