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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…