Python, Dıscord img Scraping Python 3.8

First of all sorry for my bad English. I want to pull the link on discord.com but somehow I couldn't. This is an image link.

enter image description here

I'm new to python, it seems like a difficult project for me. I'm waiting for your help. I'm using python 3.8.

This is the output:

Sunucu ID Giriniz : 644945540873846815 Sunucudaki Bir Odanın IDsini Giriniz : 779477013962293249 200 | Sunucuya Ulaşıldı Traceback (most recent call last): File "Discord Badge Searcher.py", line 70, in url_oku=urllib.request.urlopen(url) File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 222, in urlopen return opener.open(url, data, timeout) File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 531, in open response = meth(req, response) File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 640, in http_response response = self.parent.error( File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 569, in error return self._call_chain(*args) File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 502, in _call_chain result = func(*args) File "C:\Users\theto\AppData\Local\Programs\Python\Python38\lib\urllib\request.py", line 649, in http_error_default raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

This is the code so far:

if (degergir == Deger1):
sunucuid = input('Sunucu ID Giriniz :  ')
odaid = input('Sunucudaki Bir Odanın IDsini Giriniz : ')
gidis2 = 'https://discord.com/channels/{sunucuid}/{odaid}/'
r = requests.post(f'https://discord.com/channels/{sunucuid}/{odaid}/', headers=headers)
if r.status_code == 200:
    print('200 | Sunucuya Ulaşıldı ')
    while True:
        url = 'https://discord.com/channels/{sunucuid}/{odaid}/'
        url_oku=urllib.request.urlopen(url)
        soup=BeautifulSoup(url_oku,'html.parser') 
        aranan=soup.find_all('img',attrs={'class':'avatar-VxgULZ da-avatar'})
        print(aranan[0])
        pyautogui.scroll(3)
        dosya = open("Discord Early.txt","a",encoding="utf-8")
        dosya.write(aranan)
        dosya.write('\n')
elif r.status_code == 429:
    data = json.loads(r.text)
    print(f'429 | Bİr Hata Var {data["retry_after"]}')
    time.sleep(data['retry_after'])
else:
    print(f'Error | {r.status_code} | {r.text}')


Read more here: https://stackoverflow.com/questions/64941570/python-d%C4%B1scord-img-scraping-python-3-8

Content Attribution

This content was originally published by Exist pela at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: