Answer the question
In order to leave comments, you need to log in
How to write a parser into which you enter data?
Good day to all. Faced a small problem while writing a program in Python. The bottom line is this: I want to write a parser that will search for applicants by their Surnames. That is, he entered the data, and the code processes them. I use BeautifulSoup, looked for the right solution in the documentation, and as a result - nothing.
Code:
https://repl.it/join/gneabajo-joulence
Answer the question
In order to leave comments, you need to log in
Joulence thought like this:
import requests
from bs4 import BeautifulSoup
url1 = 'https://vstup.osvita.ua/y2020/r27/82/706500/'
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36'}
cs = requests.get(url1, headers=headers)
# допустим фамилия вот такая
lname = "Сокол"
soup = BeautifulSoup(cs.content, 'html.parser')
table = soup.find("table", {"class": "rwd-table"})
list_family = []
for tr in table.find_all("tr", {"class": "rstatus6"}):
for td in tr.find_all("td"):
if td["data-th"] == "ПІБ":
list_family.append(td.get_text())
# print(list_family)
# print()
result = []
for family in list_family:
# print(family)
print(family.lower().split(" ")[0])
if lname.lower() in family.lower().split(" ")[0]:
print("ok")
result.append(family)
print("=="*30)
if len(result) > 0:
print(result)
else:
print("Такой абитуриент не найден")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question