0

When I run this code I got from here, nothing happens:

import requests
import bs4

res = requests.get('https://en.wikipedia.org/wiki/Machine_learning')

soup = bs4.BeautifulSoup(res.text, 'lxml')

foo = soup.select('.mw-headline')

for i in soup.select('.mw-header'):
    print(i.text)

Everything were installed (lxml, requests, bs4)

I cannot continue his tutorial If I'm stuck here.

1 Answer 1

1

Because soup.select('.mw-header') return [], this is empty array. .mw-header cannot be found in source website!

enter image description here

I recommend you use jupyter notebook, there will be visual results if you use it.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.