بينما أقوم بتشغيل الكود في vs code باستخدام Python ولكن في الإخراج كان مثل هذا: sntax غير صالح

برمجة


عندما أقوم بتنفيذ الكود، أعتقد أن الكود به خطأ ولكن عندما أقوم بتنفيذ أي كود، كانت المحطة هكذا
مثال 01:

import requests
from bs4 import BeautifulSoup
url = "https://quotes.toscrape.com/"
response = requests.get(url)
if response.status_code == 200:
    soup = BeautifulSoup(response.text , 'html.parser')
    authors_names = soup.find_all('span',class_= 'authors')
    for author_name in authors_names:
       print(author_name.get_text())
else:
    print(f'failed to retrieve the page.status_code:{response.status_code}')

مثال 02:
أ = 5
طباعة (أ)

صالة:

File "<stdin>", line 1
    & "C:/Program Files/Python312/python.exe" "c:/Users/Dell/python.py/web scraping.py/test 11.py"

ما حاولت:

لقد قمت بإلغاء تثبيت رمز VS وتثبيته ولكني أواجه نفس المشكلة في المحطات الطرفية

الحل 1

إذا قمت بفحص النص الذي تم إرجاعه من موقع الويب هذا، فسوف تلاحظ أمرين:
1. لا توجد عناصر من النوع “span” مع فئة “المؤلفين”.
2. هناك عناصر من النوع “صغير” مع فئة “المؤلف”.

コメント

タイトルとURLをコピーしました