Python Forum
Traceback error in PyCharm but not in other IDEs?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Traceback error in PyCharm but not in other IDEs?
#6
Some advice drop urllib and use Requests.
Here how that code would look with some advice,more here in tutorial part-1.
import requests
from bs4 import BeautifulSoup

url = "https://www.bbc.com/sport/football/46897172"
response = requests.get(url)
# lxml is faster parser
soup = BeautifulSoup(response.content, 'lxml')
# Now do not use dict call,easier to copy from page and just add one _ after class
content = soup.find('div', class_="story-body sp-story-body gel-body-copy")

with open('scraped_text.txt', 'w') as f_out:
    for p_tag in content.find_all('p'):
        print(p_tag.text)
        f_out.write(f'{p_tag.text}\n')
Reply


Messages In This Thread
RE: Traceback error in PyCharm but not in other IDEs? - by snippsat - Feb-28-2020, 06:25 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pycharm error zuri 1 533 Nov-01-2023, 03:38 PM
Last Post: deanhystad
  Python Traceback Error mg24 2 991 Nov-21-2022, 02:35 PM
Last Post: snippsat
  Keeping up with IDEs and Virtual Environments... bytecrunch 7 2,656 Sep-05-2022, 08:04 PM
Last Post: snippsat
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,404 Jun-18-2022, 01:09 PM
Last Post: snippsat
  PyCharm Error? coder_sw99 4 2,056 Sep-24-2021, 06:16 PM
Last Post: Yoriz
  Keep getting Session management error when running imshow in pycharm pace 0 2,154 Mar-25-2021, 10:06 AM
Last Post: pace
  REGEX Install Error in PyCharm charlesauspicks 1 2,810 May-14-2020, 08:10 PM
Last Post: buran
  Nameparser - Traceback error tjnichols 2 2,422 Feb-28-2020, 05:11 PM
Last Post: GodMaster
  Error in importing package in pycharm fullstop 0 2,385 Dec-12-2019, 04:03 PM
Last Post: fullstop
  can't assign to literal error in pycharm ryder5227 2 3,033 Oct-07-2019, 08:57 PM
Last Post: Bmart6969

Forum Jump:

User Panel Messages

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