How to refer to a div that contains this tag? [BeautifulSoup4]

1

I am practicing web scrapping and I would like to know how to refer to the div element of the page that I am scrapping that contains the following property

<div style="color:#000000; padding-left:55px; padding-bottom:1px; background
image:url(http://caribbeancinemas.com/VIP_bg.fw.png); 
background-repeat:no-repeat;background-position: right; min-height:127px;">

When I want to refer to him in my code he does not recognize it, my code for the moment is this

import bs4 as bs
import urllib.request

sauce = urllib.request.urlopen('http://caribbeancinemas.com/theater/downtown-center/').read()

soup = bs.BeautifulSoup(sauce, "html.parser")

style = "color:#000000; padding-left:55px; padding-bottom:1px; background
image:url(http://caribbeancinemas.com/VIP_bg.fw.png); 
background-repeat:no-repeat;background-position: right; min-height:127px;"


movies = soup.find('div', attrs={'class','column three-fourth column_column'})

titles = []
for movie in soup.find_all('div', attrs={'class', 'column three-fourth'}):
    title =  movie.b.text
    print (title)

    for div in movie.find_all('div', style=style):

        print (div.text)
    
asked by Just Half 27.02.2018 в 04:44
source

1 answer

1

You should include your style in attrs. That is, something like this:

movie.find_all('div', attrs={'style': 'color:#000000; padding-left:55px; padding-bottom:1px; background-image:url(http://caribbeancinemas.com/VIP_bg.fw.png); background-repeat:no-repeat; \n     background-position: right; min-height:127px;'})

Pay attention to the "\ n" before the background-position because there is a carriage return in the HTML code. That's probably why it's not working for you.

However, you should look for another way to find the desired element and not through such a complex style. As for example, find the second div son.

    
answered by 27.02.2018 / 05:20
source