Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
spliting html code with br tag
#11
thank you for ur effort but until now the code given don't split the text of the website
Reply
#12
Try this.
import requests
from bs4 import BeautifulSoup

url = 'https://www.ouedkniss.com/telephones'
response = requests.get(url)
soup = BeautifulSoup(response.content, 'lxml')
id_find = soup.find('div', id="ann-17449284")
text_tag = soup.find('span', class_="annonce_get_description", itemprop="description")
#print(text_tag.text)
# split
print('-' * 20)
lst = list(text_tag.stripped_strings)
print(lst)
print('-' * 20)
print(lst[0])
print(lst[1])
print(lst[2])
print('-' * 20)
for item in lst:
    print(item)
Output:
-------------------- ['Smartphones', 'Double puces', 'Bluetooth Wifi', '4G', 'Produit neuf jamais utilisé', '➡️ produits original scellÉ \r\n128 gb rom / 6gb ram \r\n➡️ vente dans un magasin avec garantie bien sur \r\n\r\n➡️ vente avec facture ××((tva disponible))×× \r\n\r\n➡️ les factures proforma disponible \r\n\r\n➡️ la livraison sur tt les wilaya. \r\n\r\n➡️ disponible tt les couleurs \r\n\r\n➡'] -------------------- Smartphones Double puces Bluetooth Wifi -------------------- Smartphones Double puces Bluetooth Wifi 4G Produit neuf jamais utilisé ➡️ produits original scellÉ 128 gb rom / 6gb ram ➡️ vente dans un magasin avec garantie bien sur ➡️ vente avec facture ××((tva disponible))×× ➡️ les factures proforma disponible ➡️ la livraison sur tt les wilaya. ➡️ disponible tt les couleurs ➡
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Populating list items to html code and create individualized html code files ChainyDaisy 0 1,561 Sep-21-2022, 07:18 PM
Last Post: ChainyDaisy
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,534 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,329 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning
  How to get the href value of a specific word in the html code julio2000 2 3,145 Mar-05-2020, 07:50 PM
Last Post: julio2000
  Embedding HTML Code in Python kendias 5 4,227 Jan-27-2019, 01:43 AM
Last Post: kendias
  Help with Python and HTML code karlo_ds 4 3,397 Oct-16-2017, 03:03 PM
Last Post: karlo_ds

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020