0

Получаю: TypeError: a bytes-like object is required, not 'ResultSet'

Как я парсю:

def get_img(filt1 = "nedvizhimost", filt2 = "doma"):
    response = requests.get(url = f"https://www.olx.ua/{filt1}/{filt2}/?search%5Border%5D=created_at%3Adesc", allow_redirects=True)
    html = BS(response.content, 'lxml')
    img = html.select('tbody > tr > td.photo-cell > a > img')
    
    for i in range(5, 44):
        with open(f"{i}.png", "wb") as file:
            file.write(img)

Структура сайта:

<td class="photo-cell" rowspan="2" width="150">
  <a class="thumb vtop inlblk rel tdnone linkWithHash linkWithHashPromoted scale4 detailsLink" href="https://www.olx.ua/d/obyavlenie/prodam-noviy-1-pov-budinok-poltava-m-n-polovki-pr-svtankoviy-11-IDMFnxs.html#8fe627080c;promoted" title="">
      <img alt="Продам новий 1-пов. будинок. Полтава, м-н Половки, пр. Світанковий 11" class="fleft" src="https://ireland.apollo.olxcdn.com:443/v1/files/jwyj76wbqpkb-UA/image;s=644x461"/>
      <span class="inlblk icon paid type2 abs zi2" title="ТОП"></span>
  </a>
</td>

1 ответ 1

0

Как тривиальный пример

import urllib.request

url = "Сюда втыкаешь спарсеный урл картинки"
img = urllib.request.urlopen(url).read()

with open("img.jpg", "wb") as output:
    out.write(img)

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.