ondergetekende / livescrape Goto Github PK
View Code? Open in Web Editor NEWA toolkit to build pythonic web scraper libraries
License: MIT License
A toolkit to build pythonic web scraper libraries
License: MIT License
Documentation is an significant part of this project, it needs CI/QA as well. Some ideas:
Hi Koert,
I've had an unsuccessful stab at allowing one to pass user agent strings to the requests call in livescrape. Any chance you could have a look at this? I'd like to be able to instantiate livescrape with something like
page = ScrapedPage(scrape_url='zzz', headers={'User-agent':'Mozilla something or other'})
Any chance of you having a look at this?
Thanks,
Mat
This is especially useful in conjunction with CssGroup
, where the group would find an element, and various selectors could extract attributes from that element.
Livescrape is not the only player in the scraping ecosystem. We will need to explain the reasoning behind its creation, and inform users so they can choose between Livescrape and other projects.
We should at the very least address Scrapy
Hi,
Firstly, thanks for writing this, looks really useful.
I'd like to make a couple of suggestions for the tutorial page.
I appreciate this isn't as interesting as editing code - I'm happy to send over an error-free tutorial page (or figure out git) if it's easier.
Thanks again,
Mat
I'm assuming that you didn't intend to use a decorator here?
from livescrape import ScrapedPage, Css
class GithubProjectpage(ScrapedPage):
scrape_url = "https://github.com/%(username)s/%(projectname)s/"
scrape_args = ("username", "projectname")
git_repo = @Css("input.input-monospace", attribute="value")
page = GithubProjectpage("python", "cpython")
print(page.description)
For regular attributes, we can use decorator syntax, but that won't work for CssGroup
attributes.
Perhaps something like this?
group = CssGroup(".whatever")
@group
@Css("thing")
def foo(self, value, element):
return None
Whereas the ScrapedPage
descendants use attribute access to access the members, CssMulti
uses dictionary access. This is especially confusing when the CssMulti
exposes a CssLink
. In that case you end up with access like article_index.posts[0]['author'].homepage
. I feel this should look like article_index.posts[0].author.homepage
.
Also, the name CssMulti
doesn't really cover it's intended use. I'm considering a syntax like:
class ExampleIndex(ScrapedPage):
@CssComposite(".article")
class article(ScrapedSubPage):
link = CssLink('a.main')
That way the attribute resolving can be made lazy, which will help performance. This method also allows us to use the decorator syntax, and allows definition of non-scraper things.
One disadvantage is that because the class transitions from being a class to an attribute, there is no way to not violate the Pep008 naming scheme. We could work around that by using a two-stage definition scheme, but that feels cumbersome to me.
The CssLink
extractor could provide a referer, which may help remote site to identify dead links, and improve the over all credibility of a spider.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.