I'm trying to use string replace in python but it's not working. I'm trying to replace characters with a blank space. heres my code.
def panties():
pan_url = 'http://www.panvideos.com'
html = requests.get(pan_url, headers=headers)
soup = BeautifulSoup(html.text, 'html5lib')
video_row = soup.find_all('div', {'class': 'video'})
def youtube_link(url):
youtube_page = requests.get(url, headers=headers)
soupdata = BeautifulSoup(youtube_page.text, 'html5lib')
video_row = soupdata.find('div', {'class': 'video-player'})
entries = [{'text': str(div),
} for div in video_row][3]['text']
removed = '<script type="text/javascript">jwplayer("video-setup").setup('
newstring = entries.replace(removed, "")
return newstring
entries = [{'text': div.h4.text,
'href': div.a.get('href'),
'tube': youtube_link(div.a.get('href')),
} for div in video_row][:1]
return entries
but it still returning
<script type="text/javascript">jwplayer("video-setup").setup({file:"http://www.youtube.com/watch?v=jucBuAzuZ0E",image:"http://i1.ytimg.com/vi/jucBuAzuZ0E/maxresdefault.jpg",primary:"html5",stretching:"fill","controlbar":"bottom",width:"100%",aspectratio:"16:9",autostart:"true",logo:{file:"http://www.panvideos.com/uploads/bien-png578aab16676e1.png",position:"bottom-right",link:"http://www.panvideos.com/"},sharing:{link:"http://www.panvideos.com/video/3020/alejandro-sanz-deja-que-te-bese-ft-marc-anthony-official-video-/","sites":["facebook","twitter","linkedin","pinterest","tumblr","googleplus","reddit"]}});</script>
instead of
{file:"http://www.youtube.com/watch?v=jucBuAzuZ0E",image:"http://i1.ytimg.com/vi/jucBuAzuZ0E/maxresdefault.jpg",primary:"html5",stretching:"fill","controlbar":"bottom",width:"100%",aspectratio:"16:9",autostart:"true",logo:{file:"http://www.panvideos.com/uploads/bien-png578aab16676e1.png",position:"bottom-right",link:"http://www.panvideos.com/"},sharing:{link:"http://www.panvideos.com/video/3020/alejandro-sanz-deja-que-te-bese-ft-marc-anthony-official-video-/","sites":["facebook","twitter","linkedin","pinterest","tumblr","googleplus","reddit"]}});</script>
what am I doing wrong?
replacecall that I can see, with your example input it is working as expected - you may need to check other factors. (ie debugging calls pre and post replace to compare your input to your removed text.