Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
221 views
in Technique[技术] by (71.8m points)

DOMXPath PHP Class name change dynamic

I used DOMXPath to get some text information from a website.?

$domDocument = new DOMDocument();
@$domDocument->loadHTMLFile($url);? ? ? ? ? ??
$xpath = new DOMXPath($domDocument);
$elements = $xpath->query('//span[@class="uqkIZw ka2E9k uMhVZi dgII7d z-oVg8 _88STHx cMfkVL"]');

Every time when I start the script I get and error because the span element was not found. I looked at the website and the class name has changed to = uqkIZw ka2E9k uMhVZi FxZV-M z-oVg8 pVrzNP. It seems like when something changes on the website it will automatically change the class names of elements. Is there any possibility to get an element with DOMXPath when the class name are changing?

question from:https://stackoverflow.com/questions/66066081/domxpath-php-class-name-change-dynamic

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...