Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
|
@@ -1,36 +1,55 @@
|
|
| 1 |
-
# utils.py
|
| 2 |
-
|
| 3 |
import requests
|
| 4 |
from bs4 import BeautifulSoup
|
| 5 |
|
| 6 |
def fetch_active_tenders():
|
| 7 |
url = "https://www.ppra.org.pk/dad_tenders.asp"
|
| 8 |
response = requests.get(url)
|
| 9 |
-
soup = BeautifulSoup(response.
|
|
|
|
|
|
|
| 10 |
|
| 11 |
tenders = []
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
"title": cols[2].get_text(strip=True),
|
| 22 |
-
"advertised_date": cols[3].get_text(strip=True),
|
| 23 |
-
"closing_date": cols[4].get_text(strip=True),
|
| 24 |
-
}
|
| 25 |
-
tenders.append(tender)
|
| 26 |
return tenders
|
| 27 |
|
| 28 |
-
def fetch_tender_details(
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import requests
|
| 2 |
from bs4 import BeautifulSoup
|
| 3 |
|
| 4 |
def fetch_active_tenders():
|
| 5 |
url = "https://www.ppra.org.pk/dad_tenders.asp"
|
| 6 |
response = requests.get(url)
|
| 7 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
| 8 |
+
table = soup.find("table")
|
| 9 |
+
rows = table.find_all("tr")[1:]
|
| 10 |
|
| 11 |
tenders = []
|
| 12 |
+
for row in rows:
|
| 13 |
+
cols = row.find_all("td")
|
| 14 |
+
if len(cols) >= 5:
|
| 15 |
+
tenders.append({
|
| 16 |
+
"title": cols[0].text.strip(),
|
| 17 |
+
"department": cols[1].text.strip(),
|
| 18 |
+
"closing_date": cols[3].text.strip(),
|
| 19 |
+
"link": "https://www.ppra.org.pk/" + cols[4].find("a")["href"].strip()
|
| 20 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
return tenders
|
| 22 |
|
| 23 |
+
def fetch_tender_details(url):
|
| 24 |
+
try:
|
| 25 |
+
response = requests.get(url)
|
| 26 |
+
soup = BeautifulSoup(response.text, "html.parser")
|
| 27 |
+
text = soup.get_text(separator="\n", strip=True)
|
| 28 |
+
return text[:2000] # Limit characters to prevent long input
|
| 29 |
+
except:
|
| 30 |
+
return "Could not fetch details from this link."
|
| 31 |
|
| 32 |
+
def get_ppra_resources():
|
| 33 |
+
return {
|
| 34 |
+
"Home": "https://www.ppra.org.pk/",
|
| 35 |
+
"Active Tenders": "https://www.ppra.org.pk/dad_tenders.asp",
|
| 36 |
+
"Procurement Guidelines (PDF)": "https://www.ppra.org.pk/pguidelines.pdf",
|
| 37 |
+
"PPRA Ordinance": "https://www.ppra.org.pk/ordinance.asp",
|
| 38 |
+
"Rules": "https://www.ppra.org.pk/Rules.asp",
|
| 39 |
+
"Regulations Page": "https://www.ppra.org.pk/regulation.asp",
|
| 40 |
+
"Regulations, 2024 - Disposal of Public Assets": "https://www.ppra.org.pk/SRO615I2025.pdf",
|
| 41 |
+
"Specimens for Advertisement (Amended 2024)": "https://www.ppra.org.pk/SRO461I2024.pdf",
|
| 42 |
+
"Blacklisting & Debarment Regulations 2024": "https://www.ppra.org.pk/SRO460I2024.pdf",
|
| 43 |
+
"Review Petition Rule 19(3), 2021": "https://www.ppra.org.pk/SRO19I2021.pdf",
|
| 44 |
+
"Regulation 2009": "https://www.ppra.org.pk/reg2009.pdf",
|
| 45 |
+
"Regulation 2010 - Consultancy Services": "https://www.ppra.org.pk/reg2010.pdf",
|
| 46 |
+
"Regulation 2011": "https://www.ppra.org.pk/reg2011.pdf",
|
| 47 |
+
"Eligible Bidders Tax Compliance 2015": "https://www.ppra.org.pk/reg2015.pdf",
|
| 48 |
+
"Transaction of Business Board Meeting Regulations (2021)": "https://www.ppra.org.pk/SRO15I2021.pdf",
|
| 49 |
+
"Review Petition and Grievances (SRO90I2022)": "https://www.ppra.org.pk/SRO90I2022.pdf",
|
| 50 |
+
"National Standard Procurement Docs (SRO370I2022)": "https://www.ppra.org.pk/SRO370I2022.pdf",
|
| 51 |
+
"Manner of Advertisement (SRO591I2022)": "https://www.ppra.org.pk/SRO591I2022.pdf",
|
| 52 |
+
"Declaration of Beneficial Owners (SRO592I2022)": "https://www.ppra.org.pk/SRO592I2022.pdf",
|
| 53 |
+
"E-Pak Procurement Regulation (SRO296I2023)": "https://www.ppra.org.pk/SRO296I2023.pdf",
|
| 54 |
+
"Board Info": "https://www.ppra.org.pk/board.asp"
|
| 55 |
+
}
|