M
M
Muhamed13372018-02-02 18:04:38
Python
Muhamed1337, 2018-02-02 18:04:38

How to parse desired tags in Python?

Good afternoon!
Faced such a problem.
There is a small Python script that performs authorization on the site (facebook), and performs a search.
Task: It is
necessary to parse the response that I receive from facebook.com, in the response that I receive, there are all the tags I need, but when using bs4 I get None , similarly when using the lxml
module The script itself:

#!/usr/bin/python3

import requests, re
from bs4 import BeautifulSoup

url = 'https://www.facebook.com/login.php'
data = {"email":"login", "pass":"passwd"}
query = 'Николай Соболев'
session = requests.Session()
authority = session.post(url, data=data)
search = session.get('https://www.facebook.com/search/str/{kay}/keywords_users'.format(kay=query))
content = search.text

soup = BeautifulSoup(content, 'lxml')
film_list = soup.find('div', {'class': ['_4-u2 _58b7 _4i6x _4-u8']})
print(film_list)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rostislav Grigoriev, 2018-02-03
@Muhamed1337

soup = BeautifulSoup(content, 'html5')
film_list = soup.select('div._4-u2._58b7._4i6x._4-u8')
print(film_list)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question