python


How to read and map the description of the google search result using python request ?


I used python requests to find the google search result. I'm able to find the links and descriptions but how can I map the links with its respective description.
Below is the code and its output:
req=urllib2.Request('http://www.google.com/search?hl=en&safe=off&q='+'cat')
sock=urllib2.urlopen(req)
data = sock.read()
soup = BeautifulSoup(data, 'lxml')
if(soup):
links = soup.findAll('cite')
spans = soup.find_all("span", {"class": "st"})
for link, span in ((l,s) for l in links for s in spans):
print link.text, span.get_text()
Output:
https://en.wikipedia.org/wiki/Cat, The domestic cat (Latin: Felis catus) is a small, typically furry, carnivorous mammal. They are often called house cats when kept as indoor pets or simply cats
https://en.wikipedia.org/wiki/Cat, A non-profit organisation, run entirely by volunteers who want to improve the welfare of stray cats in Singapore.
https://en.wikipedia.org/wiki/Cat, Manufacturer of construction and mining equipment, diesel and natural gas engines, industrial gas turbines, and a wide offering of related services.
www.catwelfare.org/,The domestic cat (Latin: Felis catus) is a small, typically furry, carnivorous mammal. They are often called house cats when kept as indoor pets or simply cats
www.catwelfare.org/, A non-profit organisation, run entirely by volunteers who want to improve the welfare of stray cats in Singapore.
www.catwelfare.org/, Manufacturer of construction and mining equipment, diesel and natural gas engines, industrial gas turbines, and a wide offering of related services.
etc..
The same link is mapped with all the description of the google search result.
The required output is,
https://en.wikipedia.org/wiki/Cat, The domestic cat (Latin: Felis catus) is a small, typically furry, carnivorous mammal. They are often called house cats when kept as indoor pets or simply cats
www.catwelfare.org/, A non-profit organisation, run entirely by volunteers who want to improve the welfare of stray cats in Singapore.
www.cat.com/,Manufacturer of construction and mining equipment, diesel and natural gas engines, industrial gas turbines, and a wide offering of related services.
Kindly help me to resolve this.

Related Links

How to interfacing
Collision detection with PyGame
Why is Python not setting up my cron job's time properly?[Solved]
Training Data Set in NLTK Python
Pip3 packages can't be found/used by the terminal
No recipients have been added when trying to send message with Flask-Mail
Get 503 response code from youtube, when scraping comments with python
Pip can't upgrade a built-in package in ubuntu 15.04
PyRun_SimpleString is blocking whenever import is used, never returns
What is the purpose of setuptools requirements of the form “package===version”
Django admin site not opening while running from pydev in eclipse
WebdriverWait is showing TimeoutException, if i use sleep.time it works ok
Python: Create Array from Indexed List
Overlaying n (user generated) points over a graph
How to get django model object in save method
How to pass file pointer in dll routines using ctypes in python

Categories

HOME
xbox-live
cntk
agile
wxwidgets
qpython3
visualization
extract
parse-server
apollo
docker-windows
pygame
actionscript-2
structuremap
shipping
google-plus
vuex
keystore
jboss-eap-7
ssr
dryioc
dlib
gwtp
scaling
dendrogram
multicore
esql
profile
croppic
hanami
guile
mef2
gzip
configure
android-vpn-service
spring-profiles
canvasjs
polymorphism
web-audio-api
division
salesforce-chatter
recurrence-relation
openpgp
boilerplate
microdata
constants
stress-testing
ttcn
prototypejs
rapidweaver
range-v3
production-environment
jenkins-jira-trigger
persistent
cgcontext
qos
system.web.ui.webcontrols
foxit
uiprogressview
freetype2
multifile-uploader
gherkin
gradle-eclipse
nssplitview
contour
coordinate-transformation
project-online
mongo-c-driver
eml
approval-tests
galaxy
cctray
hateoas
viper-architecture
swift2.1
android-search
utf-32
ultrawingrid
node-inspector
late-static-binding
sqljdbc
onselect
trimming
ruboto
dig
html-form-post
cgimageref
graph-coloring
bulbs
isolatedstorage
concurrent-programming
emacs23
querystringparameter
collect
noir
phpcrawl
symbol-server
external-assemblies
openwysiwyg
visual-studio-2010-beta-2
hmacsha1
weborb
standardized

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App