R
R
RoLOQ2021-09-03 19:15:35
Python
RoLOQ, 2021-09-03 19:15:35

How to change encoding in parsing?

I have this code:

import requests
from bs4 import BeautifulSoup

pastebin = 'https://pastebin.com/zCM6M9MY'
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 OPR/78.0.4093.186"}

full_page = requests.get(google_dz, headers=headers)
soup = BeautifulSoup(full_page.content, 'html.parser', from_encoding='UTF-8')

convert = soup.findAll("div", {"class": "de1"})
print(convert[0].text)

console output:
▒▒▒

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Master Ruby, 2021-09-03
@Dunaevlad

You didn't specify a variable

full_page = requests.get(google_dz, headers=headers)

instead of google_dz , put pastebin variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question