Ah yes, SLATE uses fetch
which returns a raw result of whatever http address you put it (fetch
is also used to load files). I'm using a Github Raw link so that it only returns the source code I want to download but you can also get the html of websites (eg: print(fetch("https://scrapsavage.dev/")
)
Note that there's a couple bugs with fetch:
- I can reliably crash Picotron 0.1.0b when calling
fetch()
containing a remote URL with a query string that is 60+ characters long:
-- Works print(fetch("https://example.com?ThisQueryIs59CharactersLongThisQueryIs59CharactersLongThisQ")) -- Crashes Picotron print(fetch("https://example.com?ThisQueryIs60CharactersLongThisQueryIs60CharactersLongThisQu")) |
But, if there's a /
immediately before the ?
, it works again:
-- Works now with the / print(fetch("https://example.com/?ThisQueryIs60CharactersLongThisQueryIs60CharactersLongThisQu")) |
fetch()
forces remote URLs to lowercase / is case insensitive, which breaks requests to some sites (like Fandom; its URLs are case sensitive)
Can confirm it yourself with this testing API that just echos back the requested URL:
print(fetch("https://echo.free.beeceptor.com/UPPER_case")) |
@scrapSavage are you having any trouble with fetching remote webpages in newer versions of Picotron? for the last 2-3 versions, it doesn't seem to work for me. If I try and fetch and print any of the example listed in this thread or any other website, I get no output..
You need to wrap remote fetches in coroutines in the past few versions, this helps fetches not fail for people with slow internet.
Got it! Thanks so much for the help!
[Please log in to post a comment]