This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import pandas as pd | |
| SATICI = soup.find_all("a", href=True, attrs={'class':'satici-url'}) | |
| URUN = soup.find_all("a", href=True, attrs={'class':'urun-adi'}) | |
| FIYAT = soup.find_all("div", attrs={'class':'urun-fiyat'}) | |
| ESKI_FIYAT = soup.find_all("div", attrs={'class':'urun-eski-fiyat'}) | |
| INDIRIM = soup.find_all("div", attrs={'class':'urun-discount-rate'}) | |
| satici, satici_url, urun, urun_url, fiyat, eski_fiyat, indirim = [],[],[],[],[],[],[] | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for k in soup.find_all("a", href=True, attrs={'class':'satici-url'}): | |
| print("\n",k.text) | |
| print(k['href']) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for k in soup.find_all("td", attrs={'class':'col9'}): | |
| print(k.text) | |
| for i in soup.find_all("tr", attrs={'class':'I-harfi'}): | |
| print(i.text) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import requests #!pip install requests | |
| from bs4 import BeautifulSoup #!pip install beautifulsoup4 | |
| def get_soup(TARGET_URL): | |
| page = requests.get(TARGET_URL) | |
| soup = BeautifulSoup(page.text, 'html.parser') | |
| return soup | |
| URL = 'https://bilative.github.io/sisterslab/web_scraping' | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | for day in range(x): | |
| codeMore() | |
| andMore() | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | model = KMeans(n_clusters= 4, random_state=9800) # 3 grup istiyorum | |
| cluster_df = df.iloc[:,2:8] # kumeler icin bu degiskenler secilsin olrak belirtiyorum | |
| scaler = StandardScaler() | |
| scaler.fit(cluster_df) | |
| scaled_df = scaler.transform(cluster_df) # standardizasyon | |
| scaled_df = pd.DataFrame(scaled_df, columns = cluster_df.columns) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import seaborn as sns | |
| from sklearn.cluster import KMeans | |
| hata = [] | |
| kume_sayisi = range(1,10) | |
| for k in kume_sayisi: | |
| kmeanModel = KMeans(n_clusters = k) | |
| kmeanModel.fit(scaled_df) | |
| hata.append(kmeanModel.inertia_) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def min_max_range(a): | |
| return max(a) - min(a) | |
| bmi_range = df.groupby('Age').agg({ | |
| 'bmi': min_max_range, | |
| 'Age': 'max' | |
| }) | |
| px.bar(bmi_range, x= 'Age', y= 'bmi', barmode='group') | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | fig = go.Figure() | |
| for i in ['Weight', 'Chest', 'Abdomen', 'Hip', 'bmi']: | |
| fig.add_trace( go.Box( | |
| y = df[i], | |
| name = i, | |
| boxpoints = 'all', | |
| jitter = 0.4, | |
| whiskerwidth = 0.4, | |
| marker_size = 4) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | df['dummy_count'] = 1 | |
| fig = px.pie(df, | |
| values = 'dummy_count', | |
| names = 'bmi_sonuc', | |
| title = 'BMI Gruplarina Gore Yuzdesel Dagilim') | |
| fig.update_traces( textinfo = 'percent+label') | |
| fig.show() |