简体   繁体   中英

Identifying specific Facebook post using its HTML elements

I am creating a Google chrome plugin that injects a button onto all Facebook articles/posts. On click, i would like to query the graph API that Facebook provides and receive the post that the button is injected onto from Facebook.

Does anybody know how to do this or if this is even possible?

I have tried just using JavaScript to search the HTML that the button is injected onto and navigate through the HTML elements in order to find the text content, but this gets very messy quickly.

I was just wondering if somebody knew if the HTML elements contain some sort of identifier that will allow me to query the graph API and receive the specific post im looking for. The HTML does contain the users username but not the specific post ID.

Thanks for reading.

I haven't touched the Facebook graph-API, but if you're just looking for post ID's from the home page on Facebook you can do a simple document.getElementsByClassName("uiStreamSource") and then get all <a> elements inside. The last part of each href always contains the specific post ID.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM