I'm new to Python and I'm trying to use BeautifulSoup to parse a HTML page and extract some of the content. The problem I have is that the URL I need to parse is dynamic so I can't hard code it into urllib2.urlopen like all the examples of BeautifulSoup show.
I was trying to extract the current URL from the browser using SELF but I couldn't get this to work. Can anyone post an example of how I can extract the current URL from the browser using SELF, or how I can attach BeautifulSoup to the current URL?
Any help would be greatly appreciated.
Here's my code so far:
import os
import time
import win32api
import win32com.client
import win32con
from pywinauto import application
class A(object):
def __init__(self):
self.x = self.request.url
def method_a(self):
print self.x
#start IE with a start URL of what was passed in
app = application.Application()
app.Start(r"c:\program files\internet explorer\iexplore.exe %s"% "http://www.cyclestreets.net/journey")
time.sleep(3)
#ie = app.window_(title_re = "CycleStreets Cycle journey planner")
ie = app.window_(title_re = ".*CycleStreets.*")
a = A()
a.method_a()
When I run this I get a message saying AttributeError: 'A' object has no attribute 'request'