473,749 Members | 2,665 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1709
On Aug 23, 8:33 am, gmcalen...@gmai l.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********@gmai l.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_o pener()). 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************ *************** ***********@pyt hon.org>, 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_o pener()).
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
6748
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 language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
159
13477
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 available for java and .NET, although from what i've read these seem to be not comprehensive as protection schemes
1
2278
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 script is the closet to what it is I actually want to learn to do. The error is: Traceback (most recent call last):
26
2724
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 locally-scoped-together code, in Ruby a "block" defines a closure (anonymous function). To avoid confusion let's call them Ruby block-closures. I see them as just a syntax for defining
9
2264
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 sub-directories. Each page has some fixed parts (navigation menu, header, footer) and some changing parts (body content, though in specific cases the normally fixed parts might change as well). The tool should help to keep site editing DRY every piece of data,...
9
5833
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; gstate = PyGILState_Ensure();
1
1860
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 newbie so *any* help would be very, very welcommed. Thanks in advice! cheers!
1
1576
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 newbie so *any* help would be very, very welcommed. Thanks in advice!
1
1455
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 HTMLElementCollection = doc.all Dim link As HTMLLinkElement For Each link In links ListBox1.Items.Add(link.href) Next It should send all the links to listbox1 but instead it shows nothing, whats wrong with it??
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.