import requests from bs4 import * import random def read(c): request=requests.Session() request.headers.update({'useragent':'Mozilla/5.0 (Android 7.0; Mobile; rv:62.0) Gecko/62.0 Firefox/62.0'}) url=f'http://pytesmfamil.blogfa.com/post/{c}' res=request.get(url,allow_redirects=True) my_html=BeautifulSoup(res.text,'html.parser') all_p=my_html.find_all('p',{'class':None}) print(all_p) a=(random.choice(all_p)) print(a) read(1)
<p>سبزی پلو</p>
<p>
</p>
<class 'bs4.element.Tag'>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)