473,383 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

simple spider in python

Hi everybody, i'm new to the forum so: hello everybody (should I say
"world"?) ^_^
I'm trying to do a simple spider in python which:

1) ask google a query
2) parse the data

I'm a python newbie so *any* help would be very, very welcommed.
Thanks in advice!

cheers!

Aug 23 '07 #1
5 1701
On Aug 23, 8:33 am, gmcalen...@gmail.com wrote:
Hi everybody, i'm new to the forum so: hello everybody (should I say
"world"?) ^_^
I'm trying to do a simple spider in python which:

1) ask google a query
2) parse the data

I'm a python newbie so *any* help would be very, very welcommed.
Thanks in advice!

cheers!
Take a look at the docs for urllib2.urlopen(). The examples should
give you most of what you need.
Aug 23 '07 #2
I'm trying to do a simple spider in python which:
>
1) ask google a query
2) parse the data
While you could use urllib2.urlopen() as Frederick mentioned, there is
actually a Python module built JUST for getting info from Google
queries! So check out PyGoogle: http://pygoogle.sourceforge.net/

After you install and import it like a normal Python module, you can
do things like:
doGoogleSearch("thing to query") and get results! Very easy to use.

One thing that might throw you at first: You need to get an API key
from Google, and use that when you setup the classes. The link I
pasted above has all the details.

Good luck!

-Sam

Aug 23 '07 #3
Well, it turned out that google since Dec 2006 is not giving out SOAP
api keys anymore.
What a shame! any tip? ;-)

Aug 23 '07 #4

On Aug 23, 2007, at 6:33 AM, gm********@gmail.com wrote:
Hi everybody, i'm new to the forum so: hello everybody (should I say
"world"?) ^_^
I'm trying to do a simple spider in python which:

1) ask google a query
2) parse the data

I'm a python newbie so *any* help would be very, very welcommed.
Thanks in advice!
First thing to know is that google doesn't like the User-agent header
urllib2 uses by default -- you'll have to masquerade as a browser
(google throws a 403 error if you connect as 'User-Agent: Python-
urllib/2.5': look into urllib2.build_opener()). Second thing to know
is that the interesting results have class attribute set to "l".

hope this helps,
Michael

---
Asking a person who he *is* ... is not Pythonic! --Anton Vredegoor


Aug 23 '07 #5
In message <ma**************************************@python.o rg>, Michael
Bentley wrote:
First thing to know is that google doesn't like the User-agent header
urllib2 uses by default -- you'll have to masquerade as a browser
(google throws a 403 error if you connect as 'User-Agent: Python-
urllib/2.5': look into urllib2.build_opener()).
A bit small-minded of Google, don't you think. They also block the default
user-agent header for wget.
Sep 1 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
159
by: petantik | last post by:
Are there any commercial, or otherwise obfuscators for python source code or byte code and what are their relative advantages or disadvantages. I wonder because there are some byte code protection...
1
by: bob | last post by:
Hi, I have this sample python script from the hal sources, but it doesn't work for me. This is despite other example python scripts I have to help me are working fine. The problem is that this...
26
by: brenocon | last post by:
Hi all -- Compared to the Python I know and love, Ruby isn't quite the same. However, it has at least one terrific feature: "blocks". Whereas in Python a "block" is just several lines of...
9
by: Chris Pearl | last post by:
Are there Python tools to help webmasters manage static websites? I'm talking about regenerating an entire static website - all the HTML files in their appropriate directories and...
9
by: Svein Seldal | last post by:
Hi A couple of mulithreaded C API python questions: I) The PyGILState_Ensure() simply ensures python api call ability, it doesnt actually lock the GIL, right? PyGILState_STATE gstate;...
1
by: spython | last post by:
Hi everybody, i'm new to the forum so: hello everybody (should I say "world"?) ^_^ I'm trying to do a simple spider in python which: 1) ask google a query 2) parse the data I'm a python...
1
by: luca bertini | last post by:
Hi everybody, i'm new to the forum so: hello everybody (should I say "world"?) ^_^ I'm trying to do a simple spider in python which: 1) ask google a query 2) parse the data I'm a python...
1
by: raids51 | last post by:
Im trying to create a really basic spider in vb.net but whenever i run this code it doesnt find any thing Dim doc As HTMLDocument = WebBrowser1.Document Dim links As...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.