Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrafunkamsterdam committed Feb 25, 2024
1 parent 1cb7049 commit 157bce4
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 62 deletions.
4 changes: 2 additions & 2 deletions _update_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ def get_version(project_file: Path):
if commit:
subprocess.run(f'git commit -m "{commit}"')

subprocess.run('python -m build')
subprocess.run('twine upload dist\\*')
subprocess.run('python -m build')
subprocess.run('twine upload dist\\*')

Binary file modified docs/_build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/_build/doctrees/nodriver/classes/browser.doctree
Binary file not shown.
Binary file modified docs/_build/doctrees/nodriver/quickstart.doctree
Binary file not shown.
31 changes: 30 additions & 1 deletion docs/_build/html/_sources/nodriver/classes/browser.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,37 @@
Browser class
---------------------

Some words about the Browser class
cookies
^^^^^^^^^^^^^^^^^^^^^^^

You can load and save all cookies from the browser.


.. code-block::
# save. when no filepath is given, it is saved in '.session.dat'
await browser.cookies.save()
.. code-block::
# load. when no filepath is given, it is loaded from '.session.dat'
await browser.cookies.load()
.. code-block::
# export for requests or other library
requests_style_cookies = await browser.cookies.get_all(requests_cookie_format=True)
# use in requests:
session = requests.Session()
for cookie in requests_style_cookies:
session.cookies.set_cookie(cookie)
Browser class
^^^^^^^^^^^^^^^^^^^^^^^
.. autoclass:: nodriver.Browser
:members:
:undoc-members:
Expand Down
10 changes: 6 additions & 4 deletions docs/_build/html/_sources/nodriver/quickstart.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Since it's a part of undetected-chromedriver, installation goes via

.. code-block::
# todo. use pip install nodriver instead
pip install undetected-chromedriver
--------
Expand All @@ -31,7 +32,7 @@ type or paste a few lines and off you go.

.. code-block:: python
import asyncio
import nodriver as uc
async def main():
Expand All @@ -41,17 +42,17 @@ type or paste a few lines and off you go.
await page.save_screenshot()
await page.get_content()
await page.scroll_down(150)
elems = await page.query_selector_all('*[src]')
elems = await page.select_all('*[src]')
for elem in elems:
await elem.flash()
page2 = await browser.get('https://twitter.com', new_tab=True)
page3 = await browser.get('https://pornhub.com', new_window=True)
page3 = await browser.get('https://github.com/ultrafunkamsterdam/nodriver', new_window=True)
for p in (page, page2, page3):
await p.bring_to_front()
await p.scroll_down(200)
await p # waits for most events to be processed
await p # wait for events to be processed
await p.reload()
if p != page3:
await p.close()
Expand All @@ -63,6 +64,7 @@ type or paste a few lines and off you go.
uc.loop().run_until_complete(main())
A more concrete example, which can be found in the ./example/ folder,
shows a script to create a twitter account

Expand Down
40 changes: 22 additions & 18 deletions docs/_build/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -314,24 +314,28 @@ <h3>Main objects<a class="headerlink" href="#main-objects" title="Link to this h
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="nodriver/classes/browser.html">Browser class</a><ul>
<li class="toctree-l2"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser"><code class="docutils literal notranslate"><span class="pre">Browser</span></code></a><ul>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.create"><code class="docutils literal notranslate"><span class="pre">Browser.create()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.config"><code class="docutils literal notranslate"><span class="pre">Browser.config</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.targets"><code class="docutils literal notranslate"><span class="pre">Browser.targets</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.connection"><code class="docutils literal notranslate"><span class="pre">Browser.connection</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.websocket_url"><code class="docutils literal notranslate"><span class="pre">Browser.websocket_url</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.main_tab"><code class="docutils literal notranslate"><span class="pre">Browser.main_tab</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.tabs"><code class="docutils literal notranslate"><span class="pre">Browser.tabs</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.cookies"><code class="docutils literal notranslate"><span class="pre">Browser.cookies</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.stopped"><code class="docutils literal notranslate"><span class="pre">Browser.stopped</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.wait"><code class="docutils literal notranslate"><span class="pre">Browser.wait()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.sleep"><code class="docutils literal notranslate"><span class="pre">Browser.sleep()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.get"><code class="docutils literal notranslate"><span class="pre">Browser.get()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.start"><code class="docutils literal notranslate"><span class="pre">Browser.start()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.grant_all_permissions"><code class="docutils literal notranslate"><span class="pre">Browser.grant_all_permissions()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.tile_windows"><code class="docutils literal notranslate"><span class="pre">Browser.tile_windows()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.update_targets"><code class="docutils literal notranslate"><span class="pre">Browser.update_targets()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.stop"><code class="docutils literal notranslate"><span class="pre">Browser.stop()</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="nodriver/classes/browser.html#cookies">cookies</a></li>
<li class="toctree-l2"><a class="reference internal" href="nodriver/classes/browser.html#id1">Browser class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser"><code class="docutils literal notranslate"><span class="pre">Browser</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.create"><code class="docutils literal notranslate"><span class="pre">Browser.create()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.config"><code class="docutils literal notranslate"><span class="pre">Browser.config</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.targets"><code class="docutils literal notranslate"><span class="pre">Browser.targets</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.connection"><code class="docutils literal notranslate"><span class="pre">Browser.connection</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.websocket_url"><code class="docutils literal notranslate"><span class="pre">Browser.websocket_url</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.main_tab"><code class="docutils literal notranslate"><span class="pre">Browser.main_tab</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.tabs"><code class="docutils literal notranslate"><span class="pre">Browser.tabs</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.cookies"><code class="docutils literal notranslate"><span class="pre">Browser.cookies</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.stopped"><code class="docutils literal notranslate"><span class="pre">Browser.stopped</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.wait"><code class="docutils literal notranslate"><span class="pre">Browser.wait()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.sleep"><code class="docutils literal notranslate"><span class="pre">Browser.sleep()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.get"><code class="docutils literal notranslate"><span class="pre">Browser.get()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.start"><code class="docutils literal notranslate"><span class="pre">Browser.start()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.grant_all_permissions"><code class="docutils literal notranslate"><span class="pre">Browser.grant_all_permissions()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.tile_windows"><code class="docutils literal notranslate"><span class="pre">Browser.tile_windows()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.update_targets"><code class="docutils literal notranslate"><span class="pre">Browser.update_targets()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="nodriver/classes/browser.html#nodriver.Browser.stop"><code class="docutils literal notranslate"><span class="pre">Browser.stop()</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
Expand Down
29 changes: 28 additions & 1 deletion docs/_build/html/nodriver/classes/browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,29 @@
<article role="main">
<section id="browser-class">
<span id="browser"></span><h1>Browser class<a class="headerlink" href="#browser-class" title="Link to this heading">#</a></h1>
<p>Some words about the Browser class</p>
<section id="cookies">
<h2>cookies<a class="headerlink" href="#cookies" title="Link to this heading">#</a></h2>
<p>You can load and save all cookies from the browser.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># save. when no filepath is given, it is saved in &#39;.session.dat&#39;</span>
<span class="k">await</span> <span class="n">browser</span><span class="o">.</span><span class="n">cookies</span><span class="o">.</span><span class="n">save</span><span class="p">()</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># load. when no filepath is given, it is loaded from &#39;.session.dat&#39;</span>
<span class="k">await</span> <span class="n">browser</span><span class="o">.</span><span class="n">cookies</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
</pre></div>
</div>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="c1"># export for requests or other library</span>
<span class="n">requests_style_cookies</span> <span class="o">=</span> <span class="k">await</span> <span class="n">browser</span><span class="o">.</span><span class="n">cookies</span><span class="o">.</span><span class="n">get_all</span><span class="p">(</span><span class="n">requests_cookie_format</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>

<span class="c1"># use in requests:</span>
<span class="n">session</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">Session</span><span class="p">()</span>
<span class="k">for</span> <span class="n">cookie</span> <span class="ow">in</span> <span class="n">requests_style_cookies</span><span class="p">:</span>
<span class="n">session</span><span class="o">.</span><span class="n">cookies</span><span class="o">.</span><span class="n">set_cookie</span><span class="p">(</span><span class="n">cookie</span><span class="p">)</span>
</pre></div>
</div>
</section>
<section id="id1">
<h2>Browser class<a class="headerlink" href="#id1" title="Link to this heading">#</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="nodriver.Browser">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Browser</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">config</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">**</span></span><span class="n"><span class="pre">kwargs</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="../../_modules/nodriver/core/browser.html#Browser"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#nodriver.Browser" title="Link to this definition">#</a></dt>
Expand Down Expand Up @@ -454,6 +476,7 @@

</dd></dl>

</section>
</section>

</article>
Expand Down Expand Up @@ -512,6 +535,8 @@
<div class="toc-tree">
<ul>
<li><a class="reference internal" href="#">Browser class</a><ul>
<li><a class="reference internal" href="#cookies">cookies</a></li>
<li><a class="reference internal" href="#id1">Browser class</a><ul>
<li><a class="reference internal" href="#nodriver.Browser"><code class="docutils literal notranslate"><span class="pre">Browser</span></code></a><ul>
<li><a class="reference internal" href="#nodriver.Browser.create"><code class="docutils literal notranslate"><span class="pre">Browser.create()</span></code></a></li>
<li><a class="reference internal" href="#nodriver.Browser.config"><code class="docutils literal notranslate"><span class="pre">Browser.config</span></code></a></li>
Expand All @@ -534,6 +559,8 @@
</li>
</ul>
</li>
</ul>
</li>
</ul>

</div>
Expand Down
Loading

0 comments on commit 157bce4

Please sign in to comment.