A
A
Ali2020-04-20 08:13:15
PHP
Ali, 2020-04-20 08:13:15

How to parse html in php?

I can’t figure it out, I’m parsing elements in java from the link https://vm.tiktok.com/71JnhN/, everything works in java, but now I also need to parse the same elements in php

<meta property="og:image" content="http://p16-va-default.akamaized.net/img/tos-maliva-p-0068/f321e047290d46238480727e7d3785a6~tplv-tiktok-play.image">

Elements metaOgImage = document.select("meta[property=og:image]");if (metaOgImage != null) {
String imgurl = metaOgImage.first().attr("content");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zcoder, 2020-04-20
@goodmy

In php you can use regular expressions.
An example that takes all the info between tags:
$pattern = "/\(.*)<\/div>/";
preg_match_all($pattern, $string, $matches);
echo $matches;
For your task, specify a different regular expression.
There are online services that will help you compose them (for example, regex101.com)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question