| 53 | |
| 54 | |
| 55 | async def dataprocess(htmldata): |
| 56 | bs4obj = bs4.BeautifulSoup(htmldata, "html.parser") |
| 57 | scriptsdata = bs4obj.findAll("script", {"type": "text/javascript"}) |
| 58 | datatext = "" |
| 59 | for i in scriptsdata: |
| 60 | datatext = i.text |
| 61 | if "window._sharedData =" in datatext: |
| 62 | break |
| 63 | datajson = re.findall("{(.*)}", datatext) |
| 64 | datajson = "{" + datajson[0] + "}" |
| 65 | datadict = ujson.loads(datajson) |
| 66 | maindict = {} |
| 67 | datadict = datadict["entry_data"]["PostPage"][0]["graphql"]["shortcode_media"] |
| 68 | tofind = ["owner", "location"] |
| 69 | for i in tofind: |
| 70 | try: |
| 71 | maindict[i] = datadict[i] |
| 72 | except Exception as e: |
| 73 | print(e) |
| 74 | pass |
| 75 | return maindict |
| 76 | |
| 77 | |
| 78 | async def datapullpost(future, url): |