3,655 karma · joined Oct 19, 2015 (11y ago) · 1,773 submissions
comment 8y ago · link · parent
Consider a personal relationship. You can say you love someone. You can want to love them. You can even convince yourself that you do. But you may not, in fact, love that person, and your actions will bear the betrayal.
What I'm talking about when I say "care" is caring about the business in and of itself. That's a very different thing than caring about what you get from the business. My interpretation of the OP is that the co-founder's behavior indicates that they care about what they get from the business but not the business itself. Someone who truly cares about the business itself doesn't act in ways that harm it unless they absolutely have to.
Businesses are full of people at every level who profess to "care very deeply" but don't, or who genuinely care about things that are immaterial or even detrimental to the business's success. So when I say that people like that "don't care," I am not saying that they don't care about anything or that they have no feelings of caring.
I am talking about the CEO who "cares deeply" but refuses to fire poisonous employees or make other difficult but necessary decisions, the dev who "cares" about his work but not enough to overcome procrastination, the HR people who "care deeply" about employees but actually fear them, the managers who "care" about their direct reports but treat them like shit, and so on.
comment 8y ago · link · parent
Also, you should be "respectful" by entertaining the possibility that what OP is saying is true.
comment 8y ago · link · parent
comment 8y ago · link · parent
comment 8y ago · link · parent
comment 8y ago · link · parent
I'd start by splitting out the url generation, request, and the parsing into separate functions.
First write a function that generates a list of all the urls you want to scrape. It'll take your config and number of pages as args. If the list is going to be super long then have it return a generator.
Then you'd have a function for the request that takes only the url as an arg and returns the response content. You'll want to catch session-related exceptions and http status code issues before parsing.
The parsing function should just take the response content and `hold_no` as args. You should add some code to check the objects you're generating during parsing to make sure they actually contain what you're after. For example, your `rows` variable could return an empty list for a variety of reasons that aren't exceptions but are things you'd want to catch nonetheless. For example, maybe the element(s) can't be found because they haven't loaded yet, the returned html is malformed, or you simply made a typo in your own code. Under the hood lxml is always going to return an empty list when it can't find something.
It's hard to say how to structure this given that it's part of some bigger thing we can't see. I'd probably class the whole thing, generate the full list of urls to scrape and setup your empty `holdsurl` list both in the init. Then I'd probably write a class method that just runs the whole thing and returns the `holdsurl` list, but there are other equally good options.
One thing I don't understand is why you're transferring the session to Requests at all. I don't see anything you're doing with the Session() object that you wouldn't already be able to do with Selenium/soup/lxml.
comment 8y ago · link · parent
comment 8y ago · link · parent