I have a url https://twitter.com/Javeria85685955/status/1059335612346650624
I want to get full url in Node.js on runtime. I am using puppeteer
scraping.
My Code is :
const url = require('url');
const myURL = url.parse(req.url, true);
console.log('This is a full URL: ' + JSON.stringify(myURL))
It gives me output like :
This is a full URL:
{
"protocol": null,
"slashes": null,
"auth": null,
"host": null,
"port": null,
"hostname": null,
"hash": null,
"search": null,
"query": {},
"pathname": "/",
"path": "/",
"href": "/"
}
But Required Output I need :
https://twitter.com/Javeria85685955/status/1059335612346650624
If you're using puppeteer
then why aren't you taking advantage of the puppeteer
API to retrieve your URL as follows:
const url = await page.url();
console.log(url); // This will output the current URL to the console
Seems like the simplest solution to me?
尝试这个:
const myURL = req.headers.referer;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.