Skip to content

Commit

Permalink
updated docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrafunkamsterdam committed Nov 21, 2024
1 parent ab07a8f commit 70c08c5
Show file tree
Hide file tree
Showing 24 changed files with 562 additions and 257 deletions.
63 changes: 37 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# NODRIVER

## [CLICK HERE FOR DOCS](https://ultrafunkamsterdam.github.io/nodriver/)
## for docs click [here](https://ultrafunkamsterdam.github.io/nodriver)

**This package provides next level webscraping and browser automation
using a relatively simple interface.**
Expand Down Expand Up @@ -42,45 +42,56 @@ to fully customizable everything using the entire array of
to a nodriver.Browser instance and contintue from there
* packed with helpers and utility methods for most used and important operations

<!-- * ```elem.text```
* ```elem.text_all```
### what is new

* ```elem.parent.parent.parent.attrs```
* ```anchor_elem.href and anchor_elem['href']```
* ```anchor_elem.href = 'someotherthing'; await anchor_elem.save()```
* ```elem.children[-1].children[0].children[4].parent.parent```
**tab.open_external_debugger()**

* ```await html5video_element.record_video()```
* ```await html5video_element('pause')```
* ```await html5video_element.apply('''(el) => el.currentTime = 0''')```
* ```tab = await browser.get(url, new_tab=True)```
* ```tab_win = await browser.get(url, new_window=True)```
* ```first = await tab.find('search text')```
* ```best = await tab.find('search text', best_match=True)```
* ```all_results = await tab.find_all('search text')```
* ```first_submit_button = await tab.select(selector='button[type=submit]')```
* ```inputs_in_form = await tab.select_all('form input')``` -->
lets you inspect the tab without breaking your connection

#### Installation
**tab.get_local_storage()**

Since it’s a part of undetected-chromedriver, installation goes via
get localstorage content

```default
pip install undetected-chromedriver
```
**tab.set_local_storage(dict)**

set localstorage content

**tab.add_handler(someEvent, callback)**

callback may accept a single argument (event), or 2 arguments (event, tab).

**start(expert=True)**

does some hacking for more experienced users. It disables web security and origin-trials, as well as ensures shadow-roots are always open.

### Some examples of what the api looks like

---
> * ``elem.text``
> * ``elem.text_all``
> * ``elem.parent.parent.parent.attrs``
> * ``anchor_elem.href and anchor_elem['href']``
> * ``anchor_elem.href = 'someotherthing'; await anchor_elem.save()``
> * ``elem.children[-1].children[0].children[4].parent.parent``
> * ``await html5video_element.record_video()``
> * ``await html5video_element('pause')``
> * ``await html5video_element.apply('''(el) => el.currentTime = 0''')``
> * ``tab = await browser.get(url, new_tab=True)``
> * ``tab_win = await browser.get(url, new_window=True)``
> * ``first = await tab.find('search text')``
> * ``best = await tab.find('search text', best_match=True)``
> * ``all_results = await tab.find_all('search text')``
> * ``first_submit_button = await tab.select(selector='button[type=submit]')``
> * ``inputs_in_form = await tab.select_all('form input')``
In case you don’t want undetected-chromedriver, this package can be installed
using
### Installation

```default
pip install nodriver
```

<a id="getting-started-commands"></a>

#### usage example
### usage example

The aim of this project (just like undetected-chromedriver, somewhere long ago)
is to keep it short and simple, so you can quickly open an editor or interactive session,
Expand Down
1 change: 0 additions & 1 deletion docs/_build/html/_modules/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ <h1>All modules for which code is available</h1>
<li><a href="nodriver/core/_contradict.html">nodriver.core._contradict</a></li>
<li><a href="nodriver/core/browser.html">nodriver.core.browser</a></li>
<li><a href="nodriver/core/config.html">nodriver.core.config</a></li>
<li><a href="nodriver/core/connection.html">nodriver.core.connection</a></li>
<li><a href="nodriver/core/element.html">nodriver.core.element</a></li>
<li><a href="nodriver/core/tab.html">nodriver.core.tab</a></li>
</ul>
Expand Down
36 changes: 18 additions & 18 deletions docs/_build/html/_modules/nodriver/core/element.html
Original file line number Diff line number Diff line change
Expand Up @@ -801,12 +801,12 @@ <h1>Source code for nodriver.core.element</h1><div class="highlight"><pre>
<div class="viewcode-block" id="Element.mouse_click">
<a class="viewcode-back" href="../../../nodriver/classes/element.html#nodriver.Element.mouse_click">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">mouse_click</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">button</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;left&quot;</span><span class="p">,</span>
<span class="n">buttons</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">modifiers</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="n">hold</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">_until_event</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">type</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">button</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;left&quot;</span><span class="p">,</span>
<span class="n">buttons</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="n">modifiers</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
<span class="n">hold</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">_until_event</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">type</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;native click (on element) . note: this likely does not work atm, use click() instead</span>

Expand Down Expand Up @@ -883,10 +883,10 @@ <h1>Source code for nodriver.core.element</h1><div class="highlight"><pre>
<div class="viewcode-block" id="Element.mouse_drag">
<a class="viewcode-back" href="../../../nodriver/classes/element.html#nodriver.Element.mouse_drag">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">mouse_drag</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">destination</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Element</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]],</span>
<span class="n">relative</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">steps</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">destination</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">Element</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Tuple</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">int</span><span class="p">]],</span>
<span class="n">relative</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span>
<span class="n">steps</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> drag an element to another element or target coordinates. dragging of elements should be supported by the site of course</span>
Expand Down Expand Up @@ -1150,10 +1150,10 @@ <h1>Source code for nodriver.core.element</h1><div class="highlight"><pre>
<div class="viewcode-block" id="Element.save_screenshot">
<a class="viewcode-back" href="../../../nodriver/classes/element.html#nodriver.Element.save_screenshot">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">save_screenshot</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">filename</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">PathLike</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;auto&quot;</span><span class="p">,</span>
<span class="nb">format</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;jpeg&quot;</span><span class="p">,</span>
<span class="n">scale</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">filename</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">PathLike</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;auto&quot;</span><span class="p">,</span>
<span class="nb">format</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;jpeg&quot;</span><span class="p">,</span>
<span class="n">scale</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Saves a screenshot of this element (only)</span>
Expand Down Expand Up @@ -1339,10 +1339,10 @@ <h1>Source code for nodriver.core.element</h1><div class="highlight"><pre>
<div class="viewcode-block" id="Element.record_video">
<a class="viewcode-back" href="../../../nodriver/classes/element.html#nodriver.Element.record_video">[docs]</a>
<span class="k">async</span> <span class="k">def</span> <span class="nf">record_video</span><span class="p">(</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">filename</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">folder</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="bp">self</span><span class="p">,</span>
<span class="n">filename</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">folder</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">str</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">duration</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="nb">int</span><span class="p">,</span> <span class="nb">float</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> experimental option.</span>
Expand Down
Loading

0 comments on commit 70c08c5

Please sign in to comment.