Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
72 views
in Technique[技术] by (71.8m points)

How to change some header and p tags in html using Python

I am a very small content creator I want to create a video where I change the html of a website using python. I know this can be done using beautifulSoup and requests but I don't know how??

Code for website:

enter image description here

What I tried: enter image description here

But no changes. Help

question from:https://stackoverflow.com/questions/65861734/how-to-change-some-header-and-p-tags-in-html-using-python

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For change an HTML section you can try this:

import urllib.request
import bs4 as bs
from bs4 import BeautifulSoup

url_1 = 'YOUR URL'
sauce_1  = urllib.request.urlopen(url_1).read()
soup_1 = bs.BeautifulSoup(sauce_1, 'lxml')     

for x in (soup_1.find_all('p')):
    x = 'HELLO WORLD'

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...