Question: Hello I'm starting now in programming and I'm having some problems with Scraping, I'm trying to get all the links in a category with several names, but I'm not getting isolate the cells because there are many with the same name, could someone help me? I will put the picture of my code and the url I want to get.

`

```html
url = 'http://books.toscrape.com/index.html'
reqs = requests.get(url)
if reqs.ok:
    soup = BeautifulSoup(reqs.text, 'html.parser')
    ul = soup.find('ul', {'class': 'nav nav-list'})
    for cells in ul:
        a = cells.find('a')
        link = a['href']
        #print(link)
        [print(str(lis) + '\n\n') for lis in link]
```

=== LINK IMAGE ===

I need to retrieve all urls in (li)

[![enter image description here](https://i.stack.imgur.com/mgSG4.png)](https://i.stack.imgur.com/mgSG4.png)

Answer: 
A simple, frustrating reason this may happen is due to the order of your service collection statements.

Assigning the dependant service **after** the HTTPClient will not work, it must come before:

```
// NOT WORKING - BaseAddress is null
services.AddTransient<Controller1>();
services.AddTransient<Controller2>();

services.AddHttpClient<HttpService>(client =>
{
    client.BaseAddress = new Uri(baseAdress);
});

services.AddTransient<HttpService>();

// WORKING - BaseAddress is not null
services.AddTransient<Controller1>();
services.AddTransient<Controller2>();
services.AddTransient<HttpService>();

services.AddHttpClient<HttpService>(client =>
{
    client.BaseAddress = new Uri(baseAdress);
});

```

**EDIT**

As [LIFEfreedom](https://stackoverflow.com/users/11225738/lifefreedom) rightfully pointed out in their answer: while the order of the statements has an effect here, it is not the reason for behaviour.

Both of the following statements create a transient service for the `HttpService` class:

```
services.AddTransient<HttpService>();
services.AddHttpClient<HttpService>();

```

However, when adding both of these statements only the latest one will be used, overwriting any statements before it. In my example, I only got the expected result when the `AddHttpClient` statement with the base address configuration came last.
@jack wrote a comment and several guys supported him that this is the right decision, but it is the wrong decision.

AddHttpClient creates a TService service as a Transient service, to which it passes an HttpClient created only for it

Calling first AddTransient, and then AddHttpClient<>, you add 2 implementations of one dependency and only the last added one will be returned

```cs
// Create first dependency
services.AddTransient<HttpService>();

// Create second and last dependency
services.AddHttpClient<HttpService>(client =>
{
    client.BaseAddress = new Uri(baseAdress);
});

```