add name to contact info

This commit is contained in:
Ken Yasue
2025-03-25 06:31:19 +01:00
parent 6153b70c1e
commit 3d566a408e
6 changed files with 30 additions and 2815 deletions

View File

@ -1,4 +1,27 @@
rank,Latitude,Longitude,Name of City,Country,2021 Population,2020 Population,Growth,Population Difference,Population Change rank,Latitude,Longitude,Name of City,Country,2021 Population,2020 Population,Growth,Population Difference,Population Change
1,35.6828387,139.7594549,Tokyo,Japan,37339804,37393128,-0.0014,53324,declined
2,28.6517178,77.2219388,Delhi,India,31181376,30290936,0.0294,890440,grew
3,31.2322758,121.4692071,Shanghai,China,27795702,27058480,0.0272,737222,grew
4,-23.5506507,-46.6333824,Sao Paulo,Brazil,22237472,22043028,0.0088,194444,grew
5,19.4326296,-99.1331785,Mexico City,Mexico,21918936,21782378,0.0063,136558,grew
6,23.7861979,90.4026151,Dhaka,Bangladesh,21741090,21005860,0.035,735230,grew
7,30.0443879,31.2357257,Cairo,Egypt,21322750,20900604,0.0202,422146,grew
8,39.906217,116.3912757,Beijing,China,20896820,20462610,0.0212,434210,grew
9,19.0759899,72.8773928,Mumbai,India,20667656,20411274,0.0126,256382,grew
10,34.6198813,135.490357,Osaka,Japan,19110616,19165340,-0.0029,54724,declined
11,24.8546842,67.0207055,Karachi,Pakistan,16459472,16093786,0.0227,365686,grew
12,29.5647398,106.5478767,Chongqing,China,16382376,15872179,0.0321,510197,grew
13,41.0096334,28.9651646,Istanbul,Turkey,15415197,15190336,0.0148,224861,grew
14,-34.6075682,-58.4370894,Buenos Aires,Argentina,15257673,15153729,0.0069,103944,grew
15,22.5414185,88.3576912,Kolkata,India,14974073,14850066,0.0084,124007,grew
16,-4.3217055,15.3125974,Kinshasa,DR Congo,14970460,14342439,0.0438,628021,grew
17,6.4550575,3.3941795,Lagos,Nigeria,14862111,14368332,0.0344,493779,grew
18,14.5907332,120.9809674,Manila,Philippines,14158573,13923452,0.0169,235121,grew
19,39.0856735,117.1951073,Tianjin,China,13794450,13589078,0.0151,205372,grew
20,23.1301964,113.2592945,Guangzhou,China,13635397,13301532,0.0251,333865,grew
21,-22.9110137,-43.2093727,Rio de Janeiro,Brazil,13544462,13458075,0.0064,86387,grew
22,31.5656822,74.3141829,Lahore,Pakistan,13095166,12642423,0.0358,452743,grew
23,12.9767936,77.590082,Bangalore,India,12764935,12326532,0.0356,438403,grew
24,55.7504461,37.6174943,Moscow,Russia,12593252,12537954,0.0044,55298,grew 24,55.7504461,37.6174943,Moscow,Russia,12593252,12537954,0.0044,55298,grew
25,22.555454,114.0543297,Shenzhen,China,12591696,12356820,0.019,234876,grew 25,22.555454,114.0543297,Shenzhen,China,12591696,12356820,0.019,234876,grew
26,13.0836939,80.270186,Chennai,India,11235018,10971108,0.0241,263910,grew 26,13.0836939,80.270186,Chennai,India,11235018,10971108,0.0241,263910,grew

1 rank Latitude Longitude Name of City Country 2021 Population 2020 Population Growth Population Difference Population Change
2 1 35.6828387 139.7594549 Tokyo Japan 37339804 37393128 -0.0014 53324 declined
3 2 28.6517178 77.2219388 Delhi India 31181376 30290936 0.0294 890440 grew
4 3 31.2322758 121.4692071 Shanghai China 27795702 27058480 0.0272 737222 grew
5 4 -23.5506507 -46.6333824 Sao Paulo Brazil 22237472 22043028 0.0088 194444 grew
6 5 19.4326296 -99.1331785 Mexico City Mexico 21918936 21782378 0.0063 136558 grew
7 6 23.7861979 90.4026151 Dhaka Bangladesh 21741090 21005860 0.035 735230 grew
8 7 30.0443879 31.2357257 Cairo Egypt 21322750 20900604 0.0202 422146 grew
9 8 39.906217 116.3912757 Beijing China 20896820 20462610 0.0212 434210 grew
10 9 19.0759899 72.8773928 Mumbai India 20667656 20411274 0.0126 256382 grew
11 10 34.6198813 135.490357 Osaka Japan 19110616 19165340 -0.0029 54724 declined
12 11 24.8546842 67.0207055 Karachi Pakistan 16459472 16093786 0.0227 365686 grew
13 12 29.5647398 106.5478767 Chongqing China 16382376 15872179 0.0321 510197 grew
14 13 41.0096334 28.9651646 Istanbul Turkey 15415197 15190336 0.0148 224861 grew
15 14 -34.6075682 -58.4370894 Buenos Aires Argentina 15257673 15153729 0.0069 103944 grew
16 15 22.5414185 88.3576912 Kolkata India 14974073 14850066 0.0084 124007 grew
17 16 -4.3217055 15.3125974 Kinshasa DR Congo 14970460 14342439 0.0438 628021 grew
18 17 6.4550575 3.3941795 Lagos Nigeria 14862111 14368332 0.0344 493779 grew
19 18 14.5907332 120.9809674 Manila Philippines 14158573 13923452 0.0169 235121 grew
20 19 39.0856735 117.1951073 Tianjin China 13794450 13589078 0.0151 205372 grew
21 20 23.1301964 113.2592945 Guangzhou China 13635397 13301532 0.0251 333865 grew
22 21 -22.9110137 -43.2093727 Rio de Janeiro Brazil 13544462 13458075 0.0064 86387 grew
23 22 31.5656822 74.3141829 Lahore Pakistan 13095166 12642423 0.0358 452743 grew
24 23 12.9767936 77.590082 Bangalore India 12764935 12326532 0.0356 438403 grew
25 24 55.7504461 37.6174943 Moscow Russia 12593252 12537954 0.0044 55298 grew
26 25 22.555454 114.0543297 Shenzhen China 12591696 12356820 0.019 234876 grew
27 26 13.0836939 80.270186 Chennai India 11235018 10971108 0.0241 263910 grew

File diff suppressed because it is too large Load Diff

View File

@ -28,12 +28,15 @@ async function visitCityPages(): Promise<void> {
// Visit each city's TripAdvisor page // Visit each city's TripAdvisor page
for (let i = 0; i < cities.length; i++) { for (let i = 0; i < cities.length; i++) {
const city = cities[i]; const city = cities[i];
console.log(`[${i + 1}/${cities.length}] Visiting TripAdvisor page for ${city}...`); console.log(`[${i + 1}/${cities.length}] Visiting TripAdvisor page for ${city}...`);
try { try {
const originalWindow = await driver.getWindowHandle(); const originalWindow = await driver.getWindowHandle();
await driver.get("https://www.tripadvisor.com/");
await WebDriverUtils.wait(driver);
console.log("Logo click") console.log("Logo click")
if (!await UIActions.gotoHome(driver)) throw `${city} failed`; if (!await UIActions.gotoHome(driver)) throw `${city} failed`;
@ -78,7 +81,7 @@ async function visitCityPages(): Promise<void> {
const { websiteUrl, email } = await UIActions.getWebsiteAndEmail(driver); const { websiteUrl, email } = await UIActions.getWebsiteAndEmail(driver);
console.log(`${websiteUrl} / ${email}`); console.log(`${websiteUrl} / ${email}`);
saveContactInfoToCSV(city, { websiteUrl: websiteUrl, email: email }, path.join(__dirname, '../data/contact_info.csv')); saveContactInfoToCSV(city, { name: museumName, websiteUrl: websiteUrl, email: email }, path.join(__dirname, '../data/contact_info.csv'));
} }

View File

@ -224,7 +224,7 @@ export async function getAttractionNames(driver: WebDriver): Promise<string[]> {
} }
export async function getWebsiteAndEmail(driver: WebDriver): Promise<ContactInfo> { export async function getWebsiteAndEmail(driver: WebDriver): Promise<ContactInfo> {
const result: ContactInfo = { websiteUrl: null, email: null }; const result: ContactInfo = { name: null, websiteUrl: null, email: null };
// XPath to find URL (starting with 'http' but not containing 'tripadvisor') // XPath to find URL (starting with 'http' but not containing 'tripadvisor')
const urlXPath = `//a[starts-with(@href, 'http') and not(contains(@href, 'tripadvisor'))]`; const urlXPath = `//a[starts-with(@href, 'http') and not(contains(@href, 'tripadvisor'))]`;

View File

@ -1,4 +1,5 @@
export interface ContactInfo { export interface ContactInfo {
name: string | null,
websiteUrl: string | null; websiteUrl: string | null;
email: string | null; email: string | null;
} }

View File

@ -58,7 +58,7 @@ export class WebDriverUtils {
export function saveContactInfoToCSV(city: string, contactInfo: ContactInfo, filePath: string): void { export function saveContactInfoToCSV(city: string, contactInfo: ContactInfo, filePath: string): void {
const headers = 'City,Website URL,Email\n'; const headers = 'City,Website URL,Email\n';
const line = `"${city},"${contactInfo.websiteUrl}","${contactInfo.email}"\n`; const line = `"${city}","${contactInfo.name}","${contactInfo.websiteUrl}","${contactInfo.email}"\n`;
if (!existsSync(filePath)) { if (!existsSync(filePath)) {
writeFileSync(filePath, headers + line); writeFileSync(filePath, headers + line);