All posts tagged “Beautiful Soup”

Twitter feed on Python using YQL and BeautifulSoup

Uses YQL’s Rest query (select * from twitter.user.timeline where id=’vetri02′)

import urllib2

from BeautifulSoup import BeautifulStoneSoup

var = raw_input("Enter your Twitter id: ")

print "Tweets of", var

er = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20twitter.user.timeline%20where%20id%3D'"

fg = "'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys"

zx = er+var+fg

page = urllib2.urlopen(zx)

soup = BeautifulStoneSoup(page)

tweet = soup.findAll('text')

for twt in tweet:

    print twt.string

On Github

https://github.com/vetri02/Twitter-feed-on-Python-using-YQL-and-BeautifulSoup

 

 

Retreive data from google spreadsheet using python and beautiful soup

Create a spreadsheet on google doc share it and publish as web page ,take the url and put it instead of the URL pasted here on the code.You can retrieve the column values accordingly by changing the class name on soup.findAll (eg.:’class’ : ‘s1′)

import urllib2
from BeautifulSoup import BeautifulSoup

page = urllib2.urlopen("https://spreadsheets.google.com/pub?key=0AujzeBNXnyI-dDNBRFJZaTZyRnZnMzdnQlFzSkRsd2c&hl=en&output=html")

soup = BeautifulSoup(page)
ted = soup.findAll('td',{ 'class' : 's1'})
for td in ted:
print td.string