Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16743

PyCharm: Cannot find reference 'attrs' in 'PageElement | None'

$
0
0

I'm in PyCharm and I'm getting this strange "cannot find reference" error when using BeautifulSoup. I've followed other mentions of similar issues on here, but the warning persists. I'm getting a warning on the below code right on the last 'attrs' mention. Any idea how I prevent this warning from happening?

soup = BeautifulSoup(page.content, 'html.parser')my_date = soup.find('meta', attrs={'name': 'date'})my_record['last_update'] = my_date.attrs['content']

On this last 'attrs' variable, I'm getting an error saying:

Cannot find reference 'attrs' in 'PageElement | None'

I'm on Windows with PyCharm 2023.3.5 (Community Edition) with Python 3.9, BeatifulSoup 4.13.0b2

I've tried adding the src folders to pythonpath and "invalidated caches" which fixed it. But once everything indexes again, the problem comes back. What am I doing wrong? I tried different ways of writing the same code; the all worked but the error remains.


Viewing all articles
Browse latest Browse all 16743

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>