Python Forum
Error while scraping links with beautiful soup
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error while scraping links with beautiful soup
#1
I am getting error while scraping links with beautiful soup. Here is the program.

from urllib.request import urlopen
from bs4 import BeautifulSoup
websitecode = urlopen("https://www.google.com").read()
soup=BeautifulSoup(websitecode, "html.parser")
links=soup.findAll("a")
print(links)
Here is the error.

Error:
Traceback (most recent call last): File "test.py", line 7, in <module> print(links) File "C:\Python34\lib\encodings\cp437.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_map)[0] UnicodeEncodeError: 'charmap' codec can't encode characters in position 1308-131 3: character maps to <undefined>
I am using python 3.4.3. I appreciate the forum's cooperation.

The issue has been resolved with requests and encode("utf-8").
Reply


Messages In This Thread
Error while scraping links with beautiful soup - by mgtheboss - Dec-22-2017, 10:42 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Scraping links and table from link cartonics 11 1,608 Oct-12-2023, 06:42 AM
Last Post: cartonics
  I am scraping a web page but got an Error Sarmad54 3 1,458 Mar-02-2023, 08:20 PM
Last Post: Sarmad54
  Beautiful Soup - access a rating value in a class KatMac 1 3,477 Apr-16-2021, 01:27 PM
Last Post: snippsat
  *Beginner* web scraping/Beautiful Soup help 7ken8 2 2,621 Jan-28-2021, 04:26 PM
Last Post: 7ken8
  Help: Beautiful Soup - Parsing HTML table ironfelix717 2 2,700 Oct-01-2020, 02:19 PM
Last Post: snippsat
  error in code web scraping alexisbrunaux 5 3,815 Aug-19-2020, 02:31 AM
Last Post: alexisbrunaux
  Beautiful Soup (suddenly) doesn't get full webpage html j.crater 8 16,964 Jul-11-2020, 04:31 PM
Last Post: j.crater
  error zomato scraping data syxzetenz 3 3,381 Jun-23-2020, 08:53 PM
Last Post: Gribouillis
  Requests-HTML vs Beautiful Soup - How to Choose? robin73 0 3,829 Jun-23-2020, 02:53 PM
Last Post: robin73
  Web scraping error jithin123 0 2,441 Mar-22-2020, 08:13 PM
Last Post: jithin123

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020