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

Is LASSO regression implemented in Statsmodels?
There is a duplicate line showed when calling a __init__ in Python script
trouble with mousewheel + scrollbars in tkinter
Python Cutting a string on a certain point
Ansible become_user error UnicodeEncodeError: 'ascii' codec can't encode character
Dynamic way to create new columns as a function of existing columns in pandas
polymorphic dispatch: distinguishing Python integers vs. floating-point numbers vs. strings
HTCondor output files: obtain created directory
getting select values with flask [duplicate]
Tensorflow tf.matmul example is incorrect?
drawing flower with python turtle
Python while loop iteration does not work
Rows not displaying properly in Tkinter GUI
Getting InvalidArgumentError in Tensorflow
Django - 2 URLS with same regex, but different variables and views
Parse headers with urllib2 if there is a duplicate [duplicate]

Categories

HOME
rest
jenkins-plugins
erlang
antivirus
label
deep-linking
playframework
docker-swarm
wampserver
specflow
apple-numbers
google-spreadsheet-api
tee
activesync
symfony-forms
equalizer
uisplitviewcontroller
ssms-2016
prediction
multiplayer
yosys
hanami
bus-error
image-quality
mayavi
vertex-buffer
superagent
clockwork
read-write
honeysql
css-counter
openshift-enterprise
oscommerce
jboss-esb
bigcartel
sql-like
meta-raspberrypi
deepstream.io
ntfs-mft
bayesian-networks
tripwire
productivity
z3py
azureportal
workflow-foundation-4.5
cgcontext
execl
communication-protocol
gmt
vici
update-site
json-schema-validator
foxit
django-filer
emokit
cmocka
portfolio
except
void
document-oriented-db
eyeql
vips
built-in
xjc
type-mismatch
ubercart
debian-based
ibm-data-studio
shift-jis
code-first-migrations
adodb
hg-git
proximity
dmp
snmp4j
alpha-transparency
uipickerviewcontroller
json-patch
chrome-for-android
healthvault
java.util.date
modeshape
facebook-sdk-3.1
installshield-2011
image-zoom
trimming
lame
android-contextmenu
vt100
pitch
autostart
symfony-2.0
signals2
webkit-transform
ihttphandler
dashcode
libavformat
webrat
oggvorbis
microsoft.ink
inline-if

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