Merhaba ;
arama butonuna bastıktan sonra konsolda istediğim verileri veriyor ama programa yazmıyor .
içinden çıkamadım yardım ederseniz sevinirim
# -*- coding: utf-8 -*-
from tkinter import *
from tkinter import scrolledtext
import requests
from parsel import Selector
import re
#ara=input("aranacak ürün : ")
def trend(): #trendyol arama
ara=str(E1.get())
ara.replace(" ","%20")
birles="https://www.trendyol.com/tum--urunler?q={}&siralama=1&qt={}&st={}".format(ara,ara,ara)
target_url=birles
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
}
response = requests.get(target_url, headers=headers)
if response.status_code == 200:
print("*" * 14)
print(" ")
selector = Selector(response.text)
REGEX = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});')
isim = selector.css('div > div.srch-rslt-cntnt > div.srch-prdcts-cntnr > div:nth-child(2) > div > div:nth-child(1) > a > div.prdct-desc-cntnr-wrppr > div.prdct-desc-cntnr > div > span.prdct-desc-cntnr-name').get()
# magaza = selector.selectorlist_cls('/html/body/div[4]/div[2]/div/div[2]/div[4]/div[2]/ul/li[1]/a/div/div/div[2]/div/span[2]/span').get()
price = selector.css('#search-app > div > div.srch-rslt-cntnt > div.srch-prdcts-cntnr > div:nth-child(2) > div > div:nth-child(1) > a > div.prdct-desc-cntnr-wrppr > div.prc-cntnr > div.prc-box-sllng').get()
print('Trendyol ÜRÜN DETAYLARI:')
print('Ürün Adı: ', REGEX.sub('', isim).strip())
# print('Mağaza: ', REGEX.sub('', magaza).strip())
print('Fiyatı: ', REGEX.sub('', price).strip())
else:
print('trendyol Bağlantı kurulamadı! HTTP Kodu: ', response.status_code)
def gitti(): #gittigidiyor arama
ara=str(E1.get())
ara.replace(" ","%20")
birles = "https://www.gittigidiyor.com/arama/?k={}&sra=hpa".format(ara)
target_url = birles
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'
}
response = requests.get(target_url, headers=headers)
if response.status_code == 200:
print("*" * 14)
print(" ")
selector = Selector(response.text)
REGEX = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});')
isim = selector.xpath(
'/html/body/div[4]/div[2]/div/div[2]/div[4]/div[2]/ul/li[1]/a/div/div/div[1]/div[1]/h3/span').get()
magaza = selector.xpath(
'/html/body/div[4]/div[2]/div/div[2]/div[4]/div[2]/ul/li[1]/a/div/div/div[2]/div/span[2]/span').get()
price = selector.xpath(
'/html/body/div[4]/div[2]/div/div[2]/div[4]/div[2]/ul/li[1]/a/div/div/div[1]/div[2]/div/div[1]/div/div/div[4]/p').get()
print('GittiGidiyor ÜRÜN DETAYLARI:')
print('Ürün Adı: ', REGEX.sub('', isim).strip())
print('Mağaza: ', REGEX.sub('', magaza).strip())
print('Fiyatı: ', REGEX.sub('', price).strip())
else:
print('GittiGidiyor Bağlantı kurulamadı! HTTP Kodu: ', response.status_code)
def n11(): #n11 arama
ara=str(E1.get())
ara.replace(" ","+")
birles = "https://www.n11.com/arama?q={}&srt=PRICE_LOW".format(ara)
target_url = birles
headers = {
'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
}
response = requests.get(target_url, headers=headers)
if response.status_code == 200:
print("*" * 14)
print(" ")
selector = Selector(response.text)
REGEX = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});')
isim = selector.xpath('/html/body/div[1]/div[2]/div/div/div[2]/section/div[2]/ul/li[1]/div/div[1]/a/h3').get()
magaza = selector.xpath('/html/body/div[1]/div[2]/div/div/div[2]/section/div[2]/ul/li[1]/div/a/span[2]').get()
price = selector.xpath('/html/body/div[1]/div[2]/div/div/div[2]/section/div[2]/ul/li[1]/div/div[2]/a/ins').get()
print('N11 ÜRÜN DETAYLARI:')
print('Ürün Adı: ', REGEX.sub('', isim).strip())
print('Mağaza: ', REGEX.sub('', magaza).strip())
print('Fiyatı: ', REGEX.sub('', price).strip())
else:
print('N11 Bağlantı kurulamadı! HTTP Kodu: ', response.status_code)
def hepsi(): # hepsiburada aram
ara=str(E1.get())
ara.replace(" ","+")
birles = "https://www.hepsiburada.com/ara?q={}&siralama=artanfiyat".format(ara)
target_url = birles
headers = {
'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
}
response = requests.get(target_url, headers=headers)
if response.status_code == 200:
print("*" * 14)
print(" ")
selector = Selector(response.text)
REGEX = re.compile('<.*?>|&([a-z0-9]+|#[0-9]{1,6}|#x[0-9a-f]{1,6});')
isim = selector.xpath(
'/html/body/div[3]/main/div[2]/div/div/div/div/div[2]/section/div[1]/div[3]/div/div/div/div/ul/li[1]/div/a/div/h3/div/p/span').get()
# magaza = selector.xpath('//*/a/span[2]').get()
price = selector.xpath(
'/html/body/div[3]/main/div[2]/div/div/div/div/div[2]/section/div[1]/div[3]/div/div/div/div/ul/li[1]/div/a/div/div[2]/span').get()
print('HepsiBurada ÜRÜN DETAYLARI:')
print('Ürün Adı: ', REGEX.sub('', isim).strip())
# print('Mağaza: ', REGEX.sub('', magaza).strip())
print('Fiyatı: ', REGEX.sub('', price).strip())
else:
print('HepsiBurada Bağlantı kurulamadı! HTTP Kodu: ', response.status_code)
def islemler(): # bütün aramaların yazdırması konsolda işliyor
trend()
n11()
hepsi()
gitti()
penc =Tk()
penc.title("Ürün Arama")
penc.geometry("300x500")
uygulama=Frame(penc)
uygulama.grid()
L1 = Label(uygulama, text="Aranılacak Ürün : ")
L1.grid(row=2,column=0)
E1 = Entry(uygulama, bd=2)
E1.grid(row=2,column=2)
arama=Button(uygulama,text='Ara',width=5,height=1,command=islemler)
arama.grid(row=2,column=3)
penc.mainloop()