i am using selenium chrome driver to scratch Linkedin's profile. I am doing analysis for my post. It is the way to get exact date from Linkedin's post in format "dd.mm.yyyy" instead of "1 month ago", "2 weeks ago"?
-
1stackoverflow.com/questions/127803/… this might help youAmruta– Amruta2020-08-24 05:14:19 +00:00Commented Aug 24, 2020 at 5:14
-
1As There is no information in the HTML of post regarding post date. I afraid you can get exact date. However based on information present there like 1 mo. , 2 Week you can do calculations and get approx date by subtracting from current system date.rahul rai– rahul rai2020-08-24 05:30:36 +00:00Commented Aug 24, 2020 at 5:30
-
Thank you Guys! The first link i do not know if it is on topicJacek Antek– Jacek Antek2020-08-24 06:13:48 +00:00Commented Aug 24, 2020 at 6:13
Add a comment
|
3 Answers
I decoded the post id to find the timestamp. Method and (js) code here: https://github.com/Ollie-Boyd/Linkedin-post-timestamp-extractor.
From the 19 digit Linkedin post ID (after some trial and error) I found we can convert the post ID to binary, then convert the first 41 binary bits to a decimal to give the UNIX timestamp in milliseconds.
7 Comments
Dawei Xu
How to make it work on job post url? The job post id is 10 digits not 19.
Ollie Boyd
Hi @DaweiXu , I had a look at the job post ID and I'm not sure there's a datetime contained within it. There could be, but I think it might be a database ID etc
Ryan
ollie-boyd.github.io/Linkedin-post-timestamp-extractor is the location of a working demo of the form. Thanks!
Nikolai Varankine
As of test done on 2024-05-27, one needs to convert the first 42 binary bits to a decimal. For example, 7200824340425195520→0110001111.1011100111.0111100101.1000000101.00 0001111100000000000000→1716810307604→Mon May 27 2024 11:45:07+0000
Ollie Boyd
Hey @NikolaiVarankine, that post works fine, try it here: ollie-boyd.github.io/Linkedin-post-timestamp-extractor . You can see from the code it's using the first 41 bits
|
For PHP you can use this
function getLinkedInPostTimestamp(string $postUrl): int
{
preg_match('/([0-9]{19})/', $postUrl, $matches);
$postId = $matches[0] ?? null;
if (!$postId) {
return null;
}
$postId = (int)base_convert(substr(decbin($postId), 0, 41), 2, 10);
return $postId;
}
You can also pass the urn:li:activity ID to the function.
Comments
Not really, if you check the html you will see that you have a basic string:
The only workaround for your problem is to create a method:
- Extract the current date (formatted as desired)
- Extract from LI how much time passed
- Create your logic based on extracted data (for hours, days, weeks, months, years) and do the math with your extracted current date. This one shouldn't be too difficult since any programming language has libraries to help you.
