S
S
slmuim2021-03-01 17:46:10
Python
slmuim, 2021-03-01 17:46:10

Parsing in python does not work, what should I do?

Hello. The task is to write a parser for this site . I wrote a script, but it does not give the result, but gives out the main page, please help.

import requests
from bs4 import BeautifulSoup

number = input('Введите номер: ') 
URL = 'https://phonebook.space/?input=%2B' + number 
HEADERS = {'user_agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:86.0) Gecko/20100101 Firefox/86.0', 'accept': '*/*'}

def getHtml(url, params=None):
    r = requests.get(url, headers = HEADERS)
    return r

def parse():
    html = getHtml(URL)
    print(html.status_code)
    print(html.text)

parse()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-03-01
@slmuim

Firstly, the user_agent header does not exist
. Secondly, why can't I parse information from the site?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question