Browse Source

Scraping

pull/175/head
Jure Šorn 9 months ago
parent
commit
a6e04fe926
2 changed files with 4 additions and 4 deletions
  1. 2
      README.md
  2. 6
      index.html

2
README.md

@ -2517,7 +2517,7 @@ from selenium import webdriver
<xpath> = //<element>[/ or // <element>] # Child: /, Descendant: //, Parent: /..
<xpath> = //<element>/following::<element> # Next sibling. Also preceding/parent/…
<element> = <tag><conditions><index> # `<tag> = */a/…`, `<index> = [1/2/…]`.
<condition> = [<sub_cond> [and/or <sub_cond>]] # `and` is same as chaining conditions.
<condition> = [<sub_cond> [and/or <sub_cond>]] # For negation use `not(<sub_cond>)`.
<sub_cond> = @<attr>="<val>" # `.="<val>"` matches complete text.
<sub_cond> = contains(@<attr>, "<val>") # Is <val> a substring of attr's value?
<sub_cond> = [//]<element> # Has matching child? Descendant if //.

6
index.html

@ -54,7 +54,7 @@
<body>
<header>
<aside>January 28, 2024</aside>
<aside>February 13, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</header>
@ -2077,7 +2077,7 @@ print(<span class="hljs-string">f'<span class="hljs-subst">{python_url}</span>,
<div><h4 id="xpathalsoavailableinbrowsersconsoleviadxxpath">XPath — also available in browser's console via <code class="python hljs"><span class="hljs-string">'$x(&lt;xpath&gt;)'</span></code>:</h4><pre><code class="python language-python hljs">&lt;xpath&gt; = //&lt;element&gt;[/ <span class="hljs-keyword">or</span> // &lt;element&gt;] <span class="hljs-comment"># Child: /, Descendant: //, Parent: /..</span>
&lt;xpath&gt; = //&lt;element&gt;/following::&lt;element&gt; <span class="hljs-comment"># Next sibling. Also preceding/parent/…</span>
&lt;element&gt; = &lt;tag&gt;&lt;conditions&gt;&lt;index&gt; <span class="hljs-comment"># `&lt;tag&gt; = */a/…`, `&lt;index&gt; = [1/2/…]`.</span>
&lt;condition&gt; = [&lt;sub_cond&gt; [<span class="hljs-keyword">and</span>/<span class="hljs-keyword">or</span> &lt;sub_cond&gt;]] <span class="hljs-comment"># `and` is same as chaining conditions.</span>
&lt;condition&gt; = [&lt;sub_cond&gt; [<span class="hljs-keyword">and</span>/<span class="hljs-keyword">or</span> &lt;sub_cond&gt;]] <span class="hljs-comment"># For negation use `not(&lt;sub_cond&gt;)`.</span>
&lt;sub_cond&gt; = @&lt;attr&gt;=<span class="hljs-string">"&lt;val&gt;"</span> <span class="hljs-comment"># `.="&lt;val&gt;"` matches complete text.</span>
&lt;sub_cond&gt; = contains(@&lt;attr&gt;, <span class="hljs-string">"&lt;val&gt;"</span>) <span class="hljs-comment"># Is &lt;val&gt; a substring of attr's value?</span>
&lt;sub_cond&gt; = [//]&lt;element&gt; <span class="hljs-comment"># Has matching child? Descendant if //.</span>
@ -2932,7 +2932,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
<footer>
<aside>January 28, 2024</aside>
<aside>February 13, 2024</aside>
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
</footer>

Loading…
Cancel
Save