Need help replacing characters
#1
Using the code

Code:
def VIDEOLINKS(url,name):
        req = urllib2.Request('http://somesitehere.com' + url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        match=re.compile('flvpathValue: "(.+?)",').findall(link)
        for url in match:
                addLink(name,url,'')


produces
Code:
http://somesite.com/flvcontent/filename.flv.flv?nvb=20110125080414_@?_nva=20110125120414_@?_sr=570_@?_ir=1140_@?_hash=0bda5f02cb1b2b8b2dc61


How can I change the characters _@?_ to a & or is this possible?

Thanks.
Reply
#2
Kasik Wrote:Using the code

Code:
def VIDEOLINKS(url,name):
        req = urllib2.Request('http://somesitehere.com' + url)
        req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
        response = urllib2.urlopen(req)
        link=response.read()
        response.close()
        match=re.compile('flvpathValue: "(.+?)",').findall(link)
        for url in match:
                addLink(name,url,'')


produces
Code:
http://somesite.com/flvcontent/filename.flv.flv?nvb=20110125080414_@?_nva=20110125120414_@?_sr=570_@?_ir=1140_@?_hash=0bda5f02cb1b2b8b2dc61

How can I change the characters _@?_ to a & or is this possible?

Thanks.

Adding this to the string .replace('_@?_','&') should work
Reply

Logout Mark Read Team Forum Stats Members Help
Need help replacing characters0