Skip to content

Commit bbedfa3

Browse files
Prashant TripathiPrashant Tripathi
authored andcommitted
upsated site map
1 parent 98a6d09 commit bbedfa3

File tree

4 files changed

+253
-60
lines changed

4 files changed

+253
-60
lines changed

.github/workflows/PanditBOT.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
python -m pip install -U pip
3030
pip install -r requirements.txt
3131
- name: Updating JSON
32-
run: python repo.py
32+
run: |
33+
python repo.py
34+
python sitemap.py
3335
- name: Git push
3436
run: |
3537
git config user.name PtPrashantTripathi
3638
git config user.email [email protected]
37-
git add repos.json
39+
git add .
3840
git commit -m "[PanditBot] Updating Repos Data $(date +%Y-%m-%d_%H-%M-%S)"
3941
git push --quiet

index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
<meta name="copyright" content="Pt. Prashant Tripathi © 2023 " />
2323
<meta name="robots" content="index, follow" />
2424
<link rel="shortcut icon" href="favicon.ico" />
25+
26+
<!-- Link to the sitemap -->
27+
<link rel="sitemap" type="application/xml" href="sitemap.php">
28+
2529
<link
2630
rel="icon"
2731
type="image/png"

sitemap.py

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
import xml.etree.ElementTree as ET
4+
from urllib.parse import urljoin
5+
6+
# Define the base URL and GitHub API URL
7+
USERNAME = "ptprashanttripathi" # Replace with the GitHub username
8+
BASE_URL = f"https://{USERNAME}.github.io/"
9+
GITHUB_API_URL = f"https://api.github.com/users/{USERNAME}/repos"
10+
11+
12+
def fetch_repos():
13+
url = GITHUB_API_URL
14+
response = requests.get(url)
15+
if response.status_code == 200:
16+
repos = response.json()
17+
return [repo["name"] for repo in repos]
18+
return []
19+
20+
21+
def fetch_page_urls(url):
22+
urls_set = set()
23+
try:
24+
urls_set.add(url)
25+
response = requests.get(url)
26+
if response.status_code == 200:
27+
soup = BeautifulSoup(response.content, "html.parser")
28+
# Fetch all anchor tags
29+
for link in soup.find_all("a", href=True):
30+
full_url = urljoin(BASE_URL, link["href"])
31+
if full_url.startswith(BASE_URL):
32+
urls_set.add(full_url)
33+
# Fetch all image tags
34+
for img in soup.find_all("img", src=True):
35+
img_url = urljoin(BASE_URL, img["src"])
36+
if img_url.startswith(BASE_URL):
37+
urls_set.add(img_url)
38+
except Exception as e:
39+
print(f"Error fetching {url}: {e}")
40+
return urls_set
41+
42+
43+
def create_sitemap(urls):
44+
urlset = ET.Element("urlset", xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
45+
for url in urls:
46+
url_elem = ET.SubElement(urlset, "url")
47+
loc_elem = ET.SubElement(url_elem, "loc")
48+
loc_elem.text = url
49+
# Optionally, add more elements like <lastmod>, <changefreq>, <priority>
50+
51+
tree = ET.ElementTree(urlset)
52+
ET.indent(tree, space="\t", level=0)
53+
54+
with open("sitemap.xml", "wb") as f:
55+
tree.write(f, encoding="utf-8", xml_declaration=True)
56+
57+
58+
if __name__ == "__main__":
59+
# Fetch repositories
60+
repos = fetch_repos()
61+
62+
all_urls = set()
63+
for repo in repos:
64+
repo_url = urljoin(BASE_URL, repo + "/")
65+
urls = fetch_page_urls(repo_url)
66+
all_urls.update(urls)
67+
68+
create_sitemap(all_urls)

sitemap.xml

Lines changed: 177 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,177 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
3-
<url>
4-
<loc>https://ptprashanttripathi.github.io</loc>
5-
<changefreq>always</changefreq>
6-
<priority>1.0</priority>
7-
</url>
8-
<url>
9-
<loc>https://ptprashanttripathi.github.io/index.html</loc>
10-
<changefreq>always</changefreq>
11-
<priority>0.8</priority>
12-
</url>
13-
<url>
14-
<loc>https://ptprashanttripathi.github.io/cloud-storage-system</loc>
15-
<changefreq>always</changefreq>
16-
<priority>0.8</priority>
17-
</url>
18-
<url>
19-
<loc>https://ptprashanttripathi.github.io/Fifteen-Puzzle</loc>
20-
<changefreq>always</changefreq>
21-
<priority>0.8</priority>
22-
</url>
23-
<url>
24-
<loc>https://ptprashanttripathi.github.io/IPL-2020-Prediction</loc>
25-
<changefreq>always</changefreq>
26-
<priority>0.8</priority>
27-
</url>
28-
<url>
29-
<loc>https://ptprashanttripathi.github.io/linkpe</loc>
30-
<changefreq>always</changefreq>
31-
<priority>0.8</priority>
32-
</url>
33-
<url>
34-
<loc>https://ptprashanttripathi.github.io/movieinfo</loc>
35-
<changefreq>always</changefreq>
36-
<priority>0.8</priority>
37-
</url>
38-
<url>
39-
<loc>https://ptprashanttripathi.github.io/OnePiece</loc>
40-
<changefreq>always</changefreq>
41-
<priority>0.8</priority>
42-
</url>
43-
<url>
44-
<loc>https://ptprashanttripathi.github.io/ptprashanttripathi</loc>
45-
<changefreq>always</changefreq>
46-
<priority>0.8</priority>
47-
</url>
48-
<url>
49-
<loc>https://ptprashanttripathi.github.io/shreeganesh</loc>
50-
<changefreq>always</changefreq>
51-
<priority>0.8</priority>
52-
</url>
53-
<url>
54-
<loc>https://ptprashanttripathi.github.io/simple-portfolio</loc>
55-
<changefreq>always</changefreq>
56-
<priority>0.8</priority>
57-
</url>
58-
</urlset>
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
3+
<url>
4+
<loc>https://ptprashanttripathi.github.io/images/pic03.png</loc>
5+
</url>
6+
<url>
7+
<loc>https://ptprashanttripathi.github.io/ptprashanttripathi/</loc>
8+
</url>
9+
<url>
10+
<loc>https://ptprashanttripathi.github.io/wings-nodejs-buysellapp/</loc>
11+
</url>
12+
<url>
13+
<loc>https://ptprashanttripathi.github.io/Bhojpuri-Translator/</loc>
14+
</url>
15+
<url>
16+
<loc>https://ptprashanttripathi.github.io/career/academic/</loc>
17+
</url>
18+
<url>
19+
<loc>https://ptprashanttripathi.github.io/gmail.com</loc>
20+
</url>
21+
<url>
22+
<loc>https://ptprashanttripathi.github.io/career/academic</loc>
23+
</url>
24+
<url>
25+
<loc>https://ptprashanttripathi.github.io/img/logo.png</loc>
26+
</url>
27+
<url>
28+
<loc>https://ptprashanttripathi.github.io/Adhyatma/</loc>
29+
</url>
30+
<url>
31+
<loc>https://ptprashanttripathi.github.io/index.html</loc>
32+
</url>
33+
<url>
34+
<loc>https://ptprashanttripathi.github.io/PortfolioTracker/</loc>
35+
</url>
36+
<url>
37+
<loc>https://ptprashanttripathi.github.io/images/pic01.png</loc>
38+
</url>
39+
<url>
40+
<loc>https://ptprashanttripathi.github.io/AzureFunctionApp_ServiceBus/</loc>
41+
</url>
42+
<url>
43+
<loc>https://ptprashanttripathi.github.io/achievements/</loc>
44+
</url>
45+
<url>
46+
<loc>https://ptprashanttripathi.github.io/</loc>
47+
</url>
48+
<url>
49+
<loc>https://ptprashanttripathi.github.io/contact/</loc>
50+
</url>
51+
<url>
52+
<loc>https://ptprashanttripathi.github.io/img/google.png</loc>
53+
</url>
54+
<url>
55+
<loc>https://ptprashanttripathi.github.io/img/twitter.png</loc>
56+
</url>
57+
<url>
58+
<loc>https://ptprashanttripathi.github.io/linkpe/</loc>
59+
</url>
60+
<url>
61+
<loc>https://ptprashanttripathi.github.io/ptprashanttripathi/banner.png</loc>
62+
</url>
63+
<url>
64+
<loc>https://ptprashanttripathi.github.io/#top</loc>
65+
</url>
66+
<url>
67+
<loc>https://ptprashanttripathi.github.io/Student-Feedback-Form/</loc>
68+
</url>
69+
<url>
70+
<loc>https://ptprashanttripathi.github.io/IPL-2020-Prediction/</loc>
71+
</url>
72+
<url>
73+
<loc>https://ptprashanttripathi.github.io/flask-learning/</loc>
74+
</url>
75+
<url>
76+
<loc>https://ptprashanttripathi.github.io/\</loc>
77+
</url>
78+
<url>
79+
<loc>https://ptprashanttripathi.github.io/portfolio/</loc>
80+
</url>
81+
<url>
82+
<loc>https://ptprashanttripathi.github.io/developer-portfolio/</loc>
83+
</url>
84+
<url>
85+
<loc>https://ptprashanttripathi.github.io/#contact_sec</loc>
86+
</url>
87+
<url>
88+
<loc>https://ptprashanttripathi.github.io/simple-portfolio/</loc>
89+
</url>
90+
<url>
91+
<loc>https://ptprashanttripathi.github.io/Main.html</loc>
92+
</url>
93+
<url>
94+
<loc>https://ptprashanttripathi.github.io/cloud-storage-system/</loc>
95+
</url>
96+
<url>
97+
<loc>https://ptprashanttripathi.github.io/github-readme-streak-stats.herokuapp.svg</loc>
98+
</url>
99+
<url>
100+
<loc>https://ptprashanttripathi.github.io/#portfolio_sec</loc>
101+
</url>
102+
<url>
103+
<loc>https://ptprashanttripathi.github.io/#project_sec</loc>
104+
</url>
105+
<url>
106+
<loc>https://ptprashanttripathi.github.io/mahamodo-api/</loc>
107+
</url>
108+
<url>
109+
<loc>https://ptprashanttripathi.github.io/#interest_sec</loc>
110+
</url>
111+
<url>
112+
<loc>https://ptprashanttripathi.github.io/movieinfo/</loc>
113+
</url>
114+
<url>
115+
<loc>https://ptprashanttripathi.github.io/PuzzleGame/</loc>
116+
</url>
117+
<url>
118+
<loc>https://ptprashanttripathi.github.io/#work</loc>
119+
</url>
120+
<url>
121+
<loc>https://ptprashanttripathi.github.io/Prashant_Tripathi_Resume.pdf</loc>
122+
</url>
123+
<url>
124+
<loc>https://ptprashanttripathi.github.io/aboutme/</loc>
125+
</url>
126+
<url>
127+
<loc>https://ptprashanttripathi.github.io/images/pic02.png</loc>
128+
</url>
129+
<url>
130+
<loc>https://ptprashanttripathi.github.io/cloud-storage-system/LICENSE</loc>
131+
</url>
132+
<url>
133+
<loc>https://ptprashanttripathi.github.io/AzureFunctionApp_API/</loc>
134+
</url>
135+
<url>
136+
<loc>https://ptprashanttripathi.github.io/images/me.jpg</loc>
137+
</url>
138+
<url>
139+
<loc>https://ptprashanttripathi.github.io/Smart-Resistance-Calculator/</loc>
140+
</url>
141+
<url>
142+
<loc>https://ptprashanttripathi.github.io/ptprashanttripathi.github.io/</loc>
143+
</url>
144+
<url>
145+
<loc>https://ptprashanttripathi.github.io/img/facebook.png</loc>
146+
</url>
147+
<url>
148+
<loc>https://ptprashanttripathi.github.io/#body</loc>
149+
</url>
150+
<url>
151+
<loc>https://ptprashanttripathi.github.io/img/banner.png</loc>
152+
</url>
153+
<url>
154+
<loc>https://ptprashanttripathi.github.io/wings-reactnode-matchschedules/</loc>
155+
</url>
156+
<url>
157+
<loc>https://ptprashanttripathi.github.io/php-social-networking-site/</loc>
158+
</url>
159+
<url>
160+
<loc>https://ptprashanttripathi.github.io/portfolio/#technical</loc>
161+
</url>
162+
<url>
163+
<loc>https://ptprashanttripathi.github.io/img/instagram.png</loc>
164+
</url>
165+
<url>
166+
<loc>https://ptprashanttripathi.github.io/Canteen-Billing-System/</loc>
167+
</url>
168+
<url>
169+
<loc>https://ptprashanttripathi.github.io/#portfolio</loc>
170+
</url>
171+
<url>
172+
<loc>https://ptprashanttripathi.github.io/#contact</loc>
173+
</url>
174+
<url>
175+
<loc>https://ptprashanttripathi.github.io/shreeganesh/</loc>
176+
</url>
177+
</urlset>

0 commit comments

Comments
 (0)