pip install bs4
. а также requests pip install requests
, через Win+R или cmdIf you look at the source code for the page, you'll see that some javascript generates the webpage. What you see in the element browser is the webpage after the script has been run, and beautifulsoup just gets the html file. In order to parse the rendered webpage you'll need to use something like Selenium to render the webpage for you.
So, for example, this is how it would look with Selenium:
from bs4 import BeautifulSoup import selenium.webdriver as webdriver url = 'http://instagram.com/umnpics/' driver = webdriver.Firefox() driver.get(url) soup = BeautifulSoup(driver.page_source) for x in soup.findAll('li', {'class':'photo'}): print x
soup.findAll('li', {'class':'photo'})
меняете на ваши нужды <span class="post-stats__comments-count" title="Читать комментарии">21</span>
import requests
from bs4 import BeautifulSoup
pageURL = "https://habr.com/ru/post/442800/"
req = requests.get(pageURL)
soup = BeautifulSoup(req.content, 'html.parser')
comments = soup.find('span', {'class': 'post-stats__comments-count'}).get_text()
print('Количество комментариев на '+ pageURL + ' : ' +comments)
var content = {
'data': [["users","<div class='dev_status_okay'>Working<\/div>",14,100.000000],
["friends","<div class='dev_status_okay'>Working<\/div>",18,100.000000],
["groups","<div class='dev_status_okay'>Working<\/div>",17,100.000000],
["photos","<div class='dev_status_okay'>Working<\/div>",19,100.000000],
["video","<div class='dev_status_okay'>Working<\/div>",84,100.000000],
["messages","<div class='dev_status_okay'>Working<\/div>",31,100.000000],
["wall","<div class='dev_status_okay'>Working<\/div>",111,100.000000],
["newsfeed","<div class='dev_status_okay'>Working<\/div>",46,100.000000],
["notes","<div class='dev_status_okay'>Working<\/div>",67,100.000000],
["likes","<div class='dev_status_okay'>Working<\/div>",19,100.000000],
["pages","<div class='dev_status_okay'>Working<\/div>",26,100.000000]],
'header': ['Methods category', 'Status', 'Performance', 'Uptime']
};
Well, the thing is the sqlite3 module doesn't likes multithread cases, you can see that in the sqlite3 module's documentation
...the Python module disallows sharing connections and cursors between threads[1]
import pyscreenshot as ImageGrab
# fullscreen
im=ImageGrab.grab()
im.show()
# part of the screen
im=ImageGrab.grab(bbox=(10,10,500,500))
im.show()
# to file
ImageGrab.grab_to_file('im.png')
from bs4 import BeautifulSoup
soup = BeautifulSoup("""
<li class="K823gt" role="menuitem">
<span> text 1 </span>
</li>
<li class="x65HGs" role="menuitem">
<span> text 2 </span>
</li>
<li class="OPZe6g" role="menuitem">
<span> text 3 </span>
</li>
""", "html.parser")
span_data = soup.find_all("li", {"role":"menuitem"})
for x in span_data:
x.find("span")
print(x.text)