Spaces:
Sleeping
Sleeping
Neurolingua
commited on
Commit
•
c74b0db
1
Parent(s):
9990a6c
Update other_function.py
Browse files- other_function.py +22 -37
other_function.py
CHANGED
@@ -112,40 +112,25 @@ def get_weather(city):
|
|
112 |
celcius=str(round((int(degree) - 32)* 5/9,1))+temperature[-2]+'C'
|
113 |
return (celcius)
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
)
|
138 |
-
|
139 |
-
# Parse the table using pandas
|
140 |
-
df = pd.read_html(table.get_attribute('outerHTML'))[0]
|
141 |
-
|
142 |
-
# Drop the 'Quintal Price' column
|
143 |
-
df.drop(columns=['Quintal Price'], inplace=True)
|
144 |
-
|
145 |
-
# Convert the data to a dictionary
|
146 |
-
d = {df.iloc[i, 0]: df.iloc[i, 1] for i in range(len(df))}
|
147 |
-
|
148 |
-
# Close the WebDriver
|
149 |
-
driver.quit()
|
150 |
-
|
151 |
-
return str(d) + ' These prices are for 1 kg'
|
|
|
112 |
celcius=str(round((int(degree) - 32)* 5/9,1))+temperature[-2]+'C'
|
113 |
return (celcius)
|
114 |
|
115 |
+
import scrapy
|
116 |
+
from scrapy.selector import Selector
|
117 |
+
from urllib.parse import urljoin
|
118 |
+
import pandas as pd
|
119 |
+
|
120 |
+
class KisanDealsSpider(scrapy.Spider):
|
121 |
+
name = 'kisan_deals'
|
122 |
+
start_urls = ['https://www.kisandeals.com/mandiprices/ALL/TAMIL-NADU/ALL']
|
123 |
+
|
124 |
+
def parse(self, response):
|
125 |
+
table = response.xpath('//table')
|
126 |
+
rows = table.xpath('//tr')
|
127 |
+
|
128 |
+
data = []
|
129 |
+
for row in rows[1:]: # Skip the header row
|
130 |
+
crop = row.xpath('//td[1]/text()').get()
|
131 |
+
rate = row.xpath('//td[2]/text()').get()
|
132 |
+
data.append({'crop': crop, 'rate': rate})
|
133 |
+
|
134 |
+
df = pd.DataFrame(data)
|
135 |
+
df = df.drop(columns=['Quintal Price'])
|
136 |
+
return str(df.to_dict('index')) + ' These prices are for 1 kg'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|