<html>
<head>
<script type="text/javascript">
document.write('<a href="http://www.google.com">f*** js</a>');
document.write("f*** js!");
</script>
</head>
<body>
<script type="text/javascript">
document.write('<a href="http://www.google.com">f*** js</a>');
document.write("f*** js!");
</script>
<div><a href="http://www.google.com">f*** js</a></div>
</body>
</html>
나는 단지 하나의 js에 의해 생성하지 않습니다 얻을
In [1]: import lxml.html as H
In [2]: f = open("test.html","r")
In [3]: c = f.read()
In [4]: doc = H.document_fromstring(c)
In [5]: doc.xpath('//a')
Out[5]: [<Element a at a01d17c>]
In [6]: a = doc.xpath('//a')[0]
In [7]: a.getparent()
Out[7]: <Element div at a01d41c>
나는 위의 HTML 페이지에있는 모든 lable가 객체를 잡기 위해 XPath를 사용합니다 ... ~ 파이어 폭스 XPath 검사기는 모든 lable을 찾을 수 있습니다!?
어떻게 할까 ??? ~!
<html>
<head>
</head>
<body>
<script language="javascript">
function over(){
a.innerHTML="mouse me"
}
function out(){
a.innerHTML="<a href='http://www.google.com'>google</a>"
}
</script>
<body><li id="a"onmouseover="over()" onmouseout="out()">mouse me</li>
</body>
</html>
제거 욕설로 .. 그것은하지만, 까다로운 일이 될 것입니다 얼마나 모르겠어요 .. –
당신은 구문 분석하고 HTML을 구문 분석하기 전에 JS를 해석해야합니다. http://www.crummy.com/software/BeautifulSoup/을 보셨습니까? –
귀하의 자바 스크립트는 주어진대로 말이되지 않습니다 - 문서의 머리 부분에 링크를 쓰고 있습니까? lxml의 관점에서, document.write의 모든 것은 파싱되지 않는 문자열 상수입니다. –