tags:

views:

83

answers:

1

hello, I'm new to python. I want to extract some text from the CNN website.
I want to use python win32com module.
EDIT: on [why win32com]
Because of javascript in website... I thought of using win32com; I have looked for other solution but without success in regard to my requirement. In fact, I wanted to use mechanize or a similiar solution but this didn't work [for me].

Is it possible to use beautifulsoup or lxml with win32com?
Anyone who knows how to extract some text from cnn webiste, please help me! Specifically I want to extract text in cnn website from 'Sponsored links' 'Money'

import win32com.client
from time import sleep
from win32com.client import Dispatch
import urllib,urllib2
from BeautifulSoup import BeautifulSoup

ie = Dispatch("InternetExplorer.Application")   
ie.Visible = 1   
ie.Navigate("http://www.cnn.com") 
sleep(15)
ie.Quit()
+1  A: 

Are you trying to parse some text on cnn's web site?

You can get the page with

import urllib
f = urllib.urlopen('http://www.cnn.com')
page = f.read()
f.close()

You can then use BeautifulSoup to find whatever it is you are looking for on page.

Why win32com, dispatch, etc.?

foosion
hi, because of javascript in website...i want to use win32com. i was looked for other solution but not so much successful with my requirement. if possible , actually i want to use mechanize or something similiar solution but couldn't success
paul
Perhaps the info in this post will be helpful: http://stackoverflow.com/questions/1546089/web-scraping-a-problem-site Otherwise, please post more detail on what you are trying to do. Do you want to follow links from both Sponsored Links on the right side and Money near the top?
foosion
Hello,actually im making web scraper.and scraping is no problem with javascript.after made scraper, i will add some other function and that time i will encounter many javascript,so why i try to use PAMIE or IEhttp://elca.pastebin.com/m52e7d8e0i was attached current scraper script source.especially i want to change 'thepage = urllib.urlopen(theurl).read()' to PAMIE method.if possible ,you can check it and correct me?thanks in advance..
paul