Skip to content

Commit

Permalink
Added notes on adding a User-Agent header when importing from a URL
Browse files Browse the repository at this point in the history
  • Loading branch information
ptmcg committed Sep 15, 2024
1 parent 5487d7c commit ff3d7c6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ Version 3.0.1
sending the output to a file. The width can now be overridden by passing an integer
`width` argument to `Table.present()`.

- Updated `how_to_use_littletable.md` with notes on adding a `User-Agent` header when
importing data from HTTP/HTTPS urls.


Version 3.0.0
-------------
Expand Down
14 changes: 14 additions & 0 deletions how_to_use_littletable.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,20 @@ _(Note: when passing username and password credentials, HTTPS URLs are strongly
exposure of credentials in unencrypted requests. `littletable` will emit a warning when importing with authentication
using an HTTP URL.)_

Some sites will use the "User-Agent" HTTP header to filter out unrestricted automated access to their site. You can add this header to your
import statement using code as in the following:

user_agent_string = (
"Mozilla/5.0"
" (Windows NT 10.0; Win64; x64)"
" AppleWebKit/537.36"
" (KHTML, like Gecko)"
" Chrome/128.0.0.0"
" Safari/537.36"
" Edg/128.0.0.0"
)
table = littletable.csv_import(url, headers={"User-Agent": user_agent_string})

Tabular output
--------------
To produce a nice tabular output for a table, you can use the embedded support for
Expand Down

0 comments on commit ff3d7c6

Please sign in to comment.