我想从一个insta用户那里获取用户名,这似乎很容易做到,但我对Python的了解还不够。有人能帮我吗?我看过这段代码,我认为它很有用,但我不知道如何使用它。在
谢谢。在
from selenium import webdriver
from bs4 import BeautifulSoup
driver= webdriver.Chrome()
driver.get('https://www.instagram.com/michaeljackson/')
soup = BeautifulSoup(driver.page_source,"lxml")
driver.quit()
for item in soup.select('._o6mpc'):
name = item.select('._kc4z2')[0].text
followers= item.select('._fd86t')[1].text
following = item.select('._fd86t')[2].text
print('Name :{}\nFollowers :{}\nFollowing :
{}'.format(name,followers,following))
我建议你在发帖前先检查一下语法。很酷。 所以,正如我们看到的代码,这是一个非常小的抓取代码。在运行代码之前,您需要遵循以下步骤。在
运行代码需要三个库。在
pip install -U selenium
。在pip install -U bs4
pip install -U lxml
然后从https://sites.google.com/a/chromium.org/chromedriver/下载chrome驱动程序
然后按
python code.py
运行代码在你的Python系统中有希望。在
相关问题 更多 >
编程相关推荐