Skip to content

Commit

Permalink
feat: gmb api
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Dec 15, 2021
1 parent d676c49 commit 548c285
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
12 changes: 8 additions & 4 deletions lib/api/browse.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ export default class Browse {

if ( !url ) break;

// await url.hover();
await url.click();

// await page.waitForNavigation();
// hover and click
try {
await url.hover();
await url.click();
}
catch ( e ) {}

await sleep( 5000 + Math.floor( Math.random() * 20000 ) );
}
Expand Down Expand Up @@ -46,6 +48,8 @@ export default class Browse {
url.hash = "";

urls[url.href] = el;

el.scrollIntoView( { "behavior": "smooth", "block": "center" } );
}
}

Expand Down
23 changes: 14 additions & 9 deletions lib/api/google/my-business.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ export default class GoogleMyBusiness {
}

// protected
// XXX
async _onBusinessFound ( page, el ) {
var res;

Expand Down Expand Up @@ -123,19 +122,25 @@ export default class GoogleMyBusiness {
}

// open and browser target site
await new Promise( resolve => {
page.context().once( "page", async page => {
await this._visitBusinessSite( page );
const websiteButton = await card.$( `a.RFlwHf` );
if ( websiteButton ) {
await new Promise( resolve => {
page.context().once( "page", async page => {
await this._visitBusinessSite( page );

resolve();
} );
resolve();
} );

card.$( `a.RFlwHf` ).then( el => el.click( { "modifiers": ["Control"] } ) );
} );
websiteButton.click( { "modifiers": ["Control"] } );
} );
}

// click to phone
const callButton = await card.$( `a[jscontroller="LWZElb"]` );
await callButton.click();
if ( callButton ) {
await callButton.click();
await sleep( 500 );
}
}
catch ( e ) {
res = result.catch( e );
Expand Down

0 comments on commit 548c285

Please sign in to comment.