Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

beautifulsoup - extracting link, text, and title within child div

from bs4 import BeautifulSoup

html = """
<div class="App">
    <div class="content">
        <div class="title">Application Name #1</div>
        <div class="image" style="background-image: url(https://img_url)">
        </div>
        <a href="http://app_url" class="signed button">install app</a>
    </div>
</div>"""

soup = BeautifulSoup(html, 'html5lib')

for div in soup.select('div.App'):
    title = div.select_one('div.title')
    link = div.select_one('a')

    print("Click here: <a href='{}'>{}</a>".format(link["href"], title.text))
Comment

PREVIOUS NEXT
Code Example
Python :: How to use a <ComboboxSelected virtual event with tkinter 
Python :: Python script to download all images from a website to a specified folder with BeautifulSoup 
Python :: lda from scratch implementation on iris python 
Python :: gremlin python import 
Python :: Compress multiple directories but exclude directory - Python zipfile(or anything native to Windows 2012+ 
Python :: map reduce and filter functions in python 
Python :: create multiple marks python for python 
Python :: ternary operator in list comprehension python 
Python :: heatmap colorbar label 
Python :: phlib examples python 
Python :: lxml etree fromstring find 
Python :: HTML default value fo radio button input type based on python variable 
Python :: Flask/Werkzeug, how to return previous page after login 
Python :: python while loop command gaming code 
Python :: EDA dataframe missing and zero values 
Python :: knn.score sklearn 
Python :: ring Creating a Multi-Dimensional Array using List 
Python :: qtextedit insert unicode 
Python :: gfxdraw circle weight 
Python :: view scrapy response in chrome from inside the spider 
Python :: talib 
Python :: how to know google index of a page using python 
Python :: Matplotlib-Object oriented interface 
Python :: highly correlated features python 
Python :: Three-dimensional Contour Plots 
Python :: how to find largest number in list python without max 
Python :: python random number 1 100 
Python :: how to incorportate a different language in python code 
Python :: “no such column” after adding a field to the model 
Python :: python execute echo to file 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =