Size: a a a

2020 April 22

YM

Yerkebulan Mukhamedkali in Python KZ
так у тебя ошибка не в этом)
источник

N

Never in Python KZ
Подробнее, уже глаза болят, замылились
источник

YM

Yerkebulan Mukhamedkali in Python KZ
ты где-то с респонса лен берешь
источник

N

Never in Python KZ
кусок исходника сюда можно кидать?
источник

YM

Yerkebulan Mukhamedkali in Python KZ
нужно)
источник

N

Never in Python KZ
#Определяем размер списка кондеров по назначению
   len_destination = len(destination)
   print('Размер списка ', len_destination)
   for count_destination in range(len_destination):
       #Получили элемент списка, ищем дочерние категории по брендам и собираем.
       print(destination[count_destination]['link'])
       #Скачиваем страницу
       html_brands = get_html(destination[count_destination]['link'])
       #print('html_brands_response', html_brands)
       
       soup_brands = BeautifulSoup(html_brands, 'html.parser')
       print('soup brands', soup_brands)
источник

YM

Yerkebulan Mukhamedkali in Python KZ
мне кажется опять не там смотришь
источник

YM

Yerkebulan Mukhamedkali in Python KZ
что такое destination
источник

N

Never in Python KZ
Yerkebulan Mukhamedkali
что такое destination
список
источник

N

Never in Python KZ
я думал определить длину списка и потом из него уже получать линки для дальнейшего разбора
источник

YM

Yerkebulan Mukhamedkali in Python KZ
имеется ввиду какой у него тип?
источник

N

Never in Python KZ
string
источник

YM

Yerkebulan Mukhamedkali in Python KZ
кароч давай код что выше чем ты скинул
источник

N

Never in Python KZ
#!/bin/python3
import requests
from bs4 import BeautifulSoup
#from lxml import html

MAIN_URL = 'https://www.almacom.kz'

URL = 'https://www.almacom.kz/products/196/'

HEADERS = {
       'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Firefox/45.0'
     }

#Типы кондеров по их назначению
destination = []

#Типы кондеров по брендам
brands = []

def get_html(url, params = None):
   r = requests.get(url, headers = HEADERS, params = params)
   return r

def get_content(html):
   #Получаем список кондиционеров по их назначению(полупромышленные, бытовые, etc... )
   soup_destination = BeautifulSoup(html, 'html.parser')
   Items_Destination = soup_destination.findAll('div', class_='category-item')
#    destination = []
   count_destination = -1
   for item_destination in Items_Destination:
       count_destination = count_destination +1
       #Составляем список кондеров по их назначению
       destination.append({
           'count': count_destination,
           'category': item_destination.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_destination.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_destination.find('img', src=True).get('src')
       })  
   print(destination)

def get_brands():
   #Определяем размер списка кондеров по назначению
   len_destination = len(destination)
   print('Размер списка ', len_destination)
   for count_destination in range(len_destination):
       #Получили элемент списка, ищем дочерние категории по брендам и собираем.
       print(destination[count_destination]['link'])
       #Скачиваем страницу
       html_brands = get_html(destination[count_destination]['link'])
       #print('html_brands_response', html_brands)
       
       soup_brands = BeautifulSoup(html_brands, 'html.parser')
       #print('soup brands', soup_brands)
       
       Items_Brands = soup_brands.findAll('div', class_='category-item')
       #brands = []
       count_brands = -1    
       for item_brand in Items_Brands:
           count_brands = count_brands + 1
           brands({
           'count': count_brands,
           'brand': item_brand.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_brand.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_brand.find('img', src=True).get('src')
       })      
       print(brands)  

def parse():
   html = get_html(URL)
   if html.status_code == 200:
       get_content(html.text)
       get_brands()
   else:    
       print('ERROR. Status code not equal 200')

parse()
источник

SA

Sultan Abilda in Python KZ
Never
#!/bin/python3
import requests
from bs4 import BeautifulSoup
#from lxml import html

MAIN_URL = 'https://www.almacom.kz'

URL = 'https://www.almacom.kz/products/196/'

HEADERS = {
       'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Firefox/45.0'
     }

#Типы кондеров по их назначению
destination = []

#Типы кондеров по брендам
brands = []

def get_html(url, params = None):
   r = requests.get(url, headers = HEADERS, params = params)
   return r

def get_content(html):
   #Получаем список кондиционеров по их назначению(полупромышленные, бытовые, etc... )
   soup_destination = BeautifulSoup(html, 'html.parser')
   Items_Destination = soup_destination.findAll('div', class_='category-item')
#    destination = []
   count_destination = -1
   for item_destination in Items_Destination:
       count_destination = count_destination +1
       #Составляем список кондеров по их назначению
       destination.append({
           'count': count_destination,
           'category': item_destination.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_destination.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_destination.find('img', src=True).get('src')
       })  
   print(destination)

def get_brands():
   #Определяем размер списка кондеров по назначению
   len_destination = len(destination)
   print('Размер списка ', len_destination)
   for count_destination in range(len_destination):
       #Получили элемент списка, ищем дочерние категории по брендам и собираем.
       print(destination[count_destination]['link'])
       #Скачиваем страницу
       html_brands = get_html(destination[count_destination]['link'])
       #print('html_brands_response', html_brands)
       
       soup_brands = BeautifulSoup(html_brands, 'html.parser')
       #print('soup brands', soup_brands)
       
       Items_Brands = soup_brands.findAll('div', class_='category-item')
       #brands = []
       count_brands = -1    
       for item_brand in Items_Brands:
           count_brands = count_brands + 1
           brands({
           'count': count_brands,
           'brand': item_brand.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_brand.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_brand.find('img', src=True).get('src')
       })      
       print(brands)  

def parse():
   html = get_html(URL)
   if html.status_code == 200:
       get_content(html.text)
       get_brands()
   else:    
       print('ERROR. Status code not equal 200')

parse()
Блин ребят. Для таких переписок существуют сайты где можно шейрить код снипеты.
источник

YM

Yerkebulan Mukhamedkali in Python KZ
Never
#!/bin/python3
import requests
from bs4 import BeautifulSoup
#from lxml import html

MAIN_URL = 'https://www.almacom.kz'

URL = 'https://www.almacom.kz/products/196/'

HEADERS = {
       'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:45.0) Gecko/20100101 Firefox/45.0'
     }

#Типы кондеров по их назначению
destination = []

#Типы кондеров по брендам
brands = []

def get_html(url, params = None):
   r = requests.get(url, headers = HEADERS, params = params)
   return r

def get_content(html):
   #Получаем список кондиционеров по их назначению(полупромышленные, бытовые, etc... )
   soup_destination = BeautifulSoup(html, 'html.parser')
   Items_Destination = soup_destination.findAll('div', class_='category-item')
#    destination = []
   count_destination = -1
   for item_destination in Items_Destination:
       count_destination = count_destination +1
       #Составляем список кондеров по их назначению
       destination.append({
           'count': count_destination,
           'category': item_destination.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_destination.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_destination.find('img', src=True).get('src')
       })  
   print(destination)

def get_brands():
   #Определяем размер списка кондеров по назначению
   len_destination = len(destination)
   print('Размер списка ', len_destination)
   for count_destination in range(len_destination):
       #Получили элемент списка, ищем дочерние категории по брендам и собираем.
       print(destination[count_destination]['link'])
       #Скачиваем страницу
       html_brands = get_html(destination[count_destination]['link'])
       #print('html_brands_response', html_brands)
       
       soup_brands = BeautifulSoup(html_brands, 'html.parser')
       #print('soup brands', soup_brands)
       
       Items_Brands = soup_brands.findAll('div', class_='category-item')
       #brands = []
       count_brands = -1    
       for item_brand in Items_Brands:
           count_brands = count_brands + 1
           brands({
           'count': count_brands,
           'brand': item_brand.find('a', title=True).get_text().strip('\n'),
           'link' : MAIN_URL + item_brand.find('a', href=True).get('href'),
           'image_link' : MAIN_URL + item_brand.find('img', src=True).get('src')
       })      
       print(brands)  

def parse():
   html = get_html(URL)
   if html.status_code == 200:
       get_content(html.text)
       get_brands()
   else:    
       print('ERROR. Status code not equal 200')

parse()
BeautifulSoup-у ты даешь объект Response
источник

YM

Yerkebulan Mukhamedkali in Python KZ
нужно что-то вроде этого сделать
html_brands = html_brands.text
источник

N

Never in Python KZ
а, догнал. Вот я тормоз
источник

N

Never in Python KZ
Благодарю!
источник

К

Кir in Python KZ
вопрос по OpenCV, читаю rgb файл
делю на каналы с помощью split и получаю три списка in8, при попытке их перемножить (просто r*g*b) получаю int8, а хотелось бы int32, как это сделать?
источник