![]() |
|
[Python] Beautiful soup - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [Python] Beautiful soup (/showthread.php?tid=5714142) |
Beautiful soup - SIM-574702 - Sep 9, 2017 I'm trying to create a web crawler and I need to get links from a website. First I planned to use regex but I found lots of comments about BS and making everything easier. Currently I'm stuck because website I want to parse has more complicated structure than tutorials and I can't find a good way to get only the links I'm interested in. The webpage I'm tying to parse: HERE What's making it hard is the fact that I don't want to get links from premium ads (they have yellow background). To go around that I've used title at top of regular ads. Also links don't start with http but just /rel/link Code from bs4 import BeautifulSoupThis returns the part of website I'm interested in but it's type is <class 'bs4.element.Tag'> and I have no idea what to do next. I guess I'm missing something really simple that would extract links from that but any solution is welcome. I would try to find regex to extract it but that would cause lots of duplicates because link is on img and title. * - vorticalbox - Sep 10, 2017 PHP Code PHP Code * - SIM-574702 - Sep 10, 2017 Exactly what I was looking for. I did the same thing with three times as much code. * - vorticalbox - Sep 11, 2017 (Sep 10, 2017 10:29 PM)matemisic Wrote: Exactly what I was looking for. I did the same thing with three times as much code. It just finding the right classes and tags PHP Code |