'How can I get all posts id from any wordpress website using Beatifulsoup?

I am trying to figure out how to scrape post IDs from any wordrpess website using beautifulsoup.

soup = BeautifulSoup(html_doc, "html.parser")

article = soup.find("article")
post_id = article["id"].split("-")[1]
print(post_id)

Result

Prints:

518551

This is the code I found online and I want the script to print IDs like the example shown above, but wondering how can I scrape all the IDs using the website URL?

How this can be achieved?

Thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source