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

self.assertTrue(post.text in response.content) – Assertion Error
How to add a path to sys.path permanently [duplicate]
Copy C structure to Python List
python error:List index out of range
While loop inside for loop?
Serialize multiple models in a single view
Iterating over a list adding attributes to an object in Python [duplicate]
Fourier Transformation vs Numpy FFT
pandas to_html no value representation
Using Pandas To Find the Number Of Periods Since the Rolling High
List Comprehension For Loop + Ternary Operation For Loop?
Pass variable to multiple templates in pybottle
Next and Before Links for a django paginated query
Python - String of Digits to Integer using Recursion?
Weird type error arising when I add to a database using SQL Alchemy
Python for loop causes system crash

Categories

HOME
converter
ajax
mql4
elixir
scipy
voip
warnings
laravel-5.3
avro
memory-leaks
wms
algorithmic-trading
iis-7.5
requirejs
google-spreadsheet-api
ng-admin
onenote-api
goutte
mongodb-query
dlib
sign
datagrip
anychart
distance
plsqldeveloper
explode
extractor
bcrypt
pentaho-report-designer
superagent
ioc-container
twitter-bootstrap-2
picturebox
smart-mobile-studio
spreedly
receipt
geo
superpowered
office365connectors
declare
jquery-multidatespicker
web-development-server
google-account
lftp
pytest-django
dojox.grid.datagrid
estimation
automator
w3-total-cache
chunked-encoding
seamless-immutable
greenhills
decompress
react-native-fbsdk
galleriffic
json-schema-validator
pagekit
emokit
axes
loose-typing
lemoon
datainputstream
jenkins-scriptler
geodjango
windows-vista
calibration
digits
criteria-api
rspec3
uos
web-component-tester
ctrlp
client-side-validation
hidden-field
genetic-programming
korma
ssms-addin
alertifyjs
kraken.js
ifft
indexing-service
slick-2.0
dynamic-proxy
cling
bignum
osx-snow-leopard
installshield-2011
sttwitter
swrl
html-form-post
visual-studio-2003
carddav
surveyor-gem
grunt-contrib-compass
soa-suite
qss
xslkey
code-conversion
gdt
ajax.beginform
datamember
easygui
charts4j
posting
rijndael
email-spec
clause
chatroom
drawtext
querypath
method-signature
weborb
hardware-infrastructure

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