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

return value of a function when assigned to variable,adding extra (),in python
Openerp v7 API function field 'one2many' type
Recursion, out of memory?
Fastest Pairwise Difference of Rows
Python uninstalled itself and will not reinstall
Python: How can I create multiple plots for the same function but with different variables?
Can I use Inception (image_retraining in tensorflow) to recognize letters
neo4j get relationship value by python
How do I rename the values in when I read pandas csv file
Using numpy in an apache storm bolt
Block Normal Key Function
django error logging : [Errno 13] Permission denied
Gensim installation problems
How can I make a Python module act as a reference for another module?
Python quit unexpectedly on Mac
NLTK and Stanford parsing

Categories

HOME
cakephp-3.x
cil
ibm-watson-cognitive
signalr
winapi
voip
docker-swarm
concourse
search-engine
sbt-assembly
appmaker
orientation
histogrammar
tumblr
file-io
actionscript-2
google-spreadsheet-api
deeplearning4j
aruco
game-maker-studio-1.4
onsen-ui2
automata
maxima
datagrip
scenebuilder
boolean-expression
embedly
autolayout
searchbar
yosys
croppic
multichoiceitems
aurelia-binding
gpib
read-write
wfp
rhel.net
socketpair
dql
concrete5-5.7
common.logging
service-fabric-stateful
taglib
asmx
email-parsing
dimple.js
nstouchbar
cgcontext
decompress
lotus
laravel-query-builder
createobject
svn-merge
cjson
packagemaker
activeweb
visible
asteriskami
listadapter
group-concat
xmp
insertion-sort
lemoon
insert-into
app.xaml
built-in
on-duplicate-key
xjc
ffprobe
pylearn
uptodate
gmaps4rails
livechat
jstat
dalekjs
bullet
openkinect
dynamic-proxy
angulartics
astyanax
leptonica
adomd.net
resgen
pep8
qtgui
android-contextmenu
tridion2009
osi
unions
galaxy-tab
libavformat
graniteds
idictionary
revision

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