-1

running into this error whilst making a script to pull headlines from a url. (edit; should add i have ensured python 3 and request, lxml, and beautiful soup modules are all installed)

UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently. The code that caused this warning is on line 9 of the file news.py. To get rid of this warning, pass the additional argument 'features="lxml"' to the BeautifulSoup constructor. soup = BeautifulSoup(r.text)

`import requests
from bs4 import BeautifulSoup
import lxml



url = 'http://www.news.google.com'
r = requests.get(url)
soup = BeautifulSoup(r.text)



for story_heading in soup.find_all(class_="story-heading"):
    print()`
  • Thats a warning — not an error. It's also probably been discussed on here many times before. – l'L'l Feb 23 '19 at 04:18

1 Answers1

0

Please do pip install lxml in your terminal/cmd to resolve this issue.

You can either use lxml or html.parser or other see the difference HERE

Example:

soup = BeautifulSoup(r.text, 'lxml')

Instead of the 'lxml' you can choose one from the docs that suits your needs.

Example (if we were to use html5lib):

soup = BeautifulSoup(r.text, 'html5lib')
innicoder
  • 2,612
  • 3
  • 14
  • 29