Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return unique_list only when link_extractor.unique is True #5458

Merged
merged 7 commits into from
Jan 12, 2023
Merged

fix: return unique_list only when link_extractor.unique is True #5458

merged 7 commits into from
Jan 12, 2023

Conversation

reidemeister94
Copy link
Contributor

@reidemeister94 reidemeister94 commented Mar 23, 2022

In the lxmlhtml.py script, the function extract_links(self, response) always returns unique_list(all_links), even when the attribute unique of the link_extractor is equal to False.

The behavior is coherent with the unique attribute with this little change in the return line.

Fixes #3798, closes #3799, closes #4695

@wRAR
Copy link
Member

wRAR commented Mar 23, 2022

See also: #3798 #4695 #3799

@reidemeister94
Copy link
Contributor Author

Ok so this won't get fixed?

@reidemeister94
Copy link
Contributor Author

Any update on this?

@Gallaecio
Copy link
Member

Added to my review queue, but it may take a while 🙇

@reidemeister94
Copy link
Contributor Author

Just a ping :D

@Gallaecio
Copy link
Member

I am OK with merging as is, provided we update the docstring of extract_links and provide a test for the change.

@reidemeister94
Copy link
Contributor Author

I updated the docstring and fixed the html used for the tests to have tests that also cover the new case (unique = false, and the output contains duplicates).
I hope that's enough for being merged :D

Copy link
Member

@Gallaecio Gallaecio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Until your tests changes I did not realize the issue only affected links with matching URL and text, but the original issue indeed describes it like that.

Thanks!

Co-authored-by: Adrián Chaves <adrian@chaves.io>
@codecov
Copy link

codecov bot commented Jan 11, 2023

Codecov Report

Merging #5458 (36b89a4) into master (4a5ef81) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #5458      +/-   ##
==========================================
- Coverage   88.87%   88.86%   -0.02%     
==========================================
  Files         162      162              
  Lines       10980    10982       +2     
  Branches     1796     1797       +1     
==========================================
  Hits         9759     9759              
- Misses        940      941       +1     
- Partials      281      282       +1     
Impacted Files Coverage Δ
scrapy/linkextractors/lxmlhtml.py 95.34% <100.00%> (+0.07%) ⬆️
scrapy/core/downloader/__init__.py 90.97% <0.00%> (-1.51%) ⬇️

@wRAR wRAR merged commit 74b8c34 into scrapy:master Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LinkExtractor with Unique = False doesn't extract fully identical Links
4 participants