siyamak:
import urllib
from bs4 import BeautifulSoup
x = urllib.urlopen("https://www.#.com").read()
y=BeatifulSoup(x , "html.parser" )
for link in y.find_all("a"):
z=link.get("href")
print(z)
print("≠=================≠)
کسی میتونه بگه چرا Urlopen ارور attr داره؟
Hilo siyamak:
7 mensajes · –T اگر از پایتون 3 استفاده میکنید این خط رو : x = urllib.urlopen("https://www.#.com").read() به خط زیر تغییر بدید: x = urllib.request.urlopen("https://www.#.com").read() یک دابل کوت (") هم در خط آخر در دستور پرینت تایپ نشدهC T این کدی هست که برای من کار میکنه import urllib from bs4 import BeautifulSoup x = urllib.request.urlopen("https://www.google.com").read() y = BeautifulSoup(x, "html.parser") for link in y.find_all("a"): z = link.get("href") print(z) print("≠=================≠")C T Enlace
haz clic para mostrarآره واقعا کار میکنه !!! خروجیش: https://www.google.com/imghp?hl=en&tab=wi ≠=================≠ https://maps.google.com/maps?hl=en&tab=wl ≠=================≠ https://play.google.com/?hl=en&tab=w8 ≠=================≠ https://www.youtube.com/?gl=US&tab=w1 ≠=================≠ https://news.google.com/nwshp?hl=en&tab=wn ≠=================≠ https://mail.google.com/mail/?tab=wm ≠=================≠ https://drive.google.com/?tab=wo ≠=================≠ https://www.google.com/intl/en/about/products?tab=wh ≠=================≠ http://www.google.com/history/optout?hl=en ≠=================≠ /preferences?hl=en ≠=================≠ https://accounts.google.com/ServiceLogin?hl=en&passive=true&continue=https://www.google.com/ ≠=================≠ /advanced_search?hl=en-IR&authuser=0 ≠=================≠ /language_tools?hl=en-IR&authuser=0 ≠=================≠ /intl/en/ads/ ≠=================≠ https://plus.google.com/116899029375914044550 ≠=================≠ /intl/en/about.html ≠=================≠ /intl/en/policies/privacy/ ≠=================≠ /intl/en/policies/terms/ ≠=================≠C