python win32com problem

Jon Clements joncle at googlemail.com
Sun Nov 15 10:36:25 EST 2009


On Nov 15, 1:08 pm, elca <high... at gmail.com> wrote:
> hello , these day im very stress of one of some strange thing.
>
> i want to enumurate inside list of url, and every enumurated url i want to
> visit
>
> i was uplod incompleted script source in here =>
>
> http://elca.pastebin.com/m6f911584
>
> if anyone can help me really appreciate
>
> thanks in advance
>
> Paul
>
> --
> View this message in context:http://old.nabble.com/python-win32com-problem-tp26358976p26358976.html
> Sent from the Python - python-list mailing list archive at Nabble.com.

How much effort have you put into this? It looks like you've just
whacked together code (that isn't valid -- where'd the magical
'buttons' variable come from), given up and cried for help.

Besides, I would suggest you're taking completely the wrong route.
You'll find it one hell of a challenge to automate a browser as you
want, that's if it supports exposing the DOM anyway. And without being
rude, would definitely be beyond your abilities from your posts to
c.l.p.

Download and install BeautifulSoup from http://www.crummy.com/software/BeautifulSoup/
- you seem to have quite a few HTML based needs in your pastebin, so
it'll come in useful for the future.

Here's a snippet to get you started:

from urllib2 import urlopen
from BeautifulSoup import BeautifulSoup as BS

url = urlopen('http://news.naver.com/main/presscenter/category.nhn')
urldata = url.read()
soup = BS(urldata)
atags = soup('a', attrs={'href': lambda L: L and L.startswith('http://
news.khan.co.kr')})
for atag in atags:
	print atag['href']

I'll leave it to you where you want to go from there (ie, follow the
links, or automate IE to open said pages etc...)

I strongly suggest reading the urllib2 and BeautifulSoup docs, and
documenting the above code snippet -- you should then understand it,
should be less stressed, and have something to refer to for similar
requirements in the future.

hth,
Jon.



More information about the Python-list mailing list