Wikipedia:Request a query/Archive 5
Appearance
![]() | This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | ← | Archive 3 | Archive 4 | Archive 5 |
Links in common between two pages, with a twist
I realize PetScan can be used to show links that appear on two pages, but I have a need for it to show such a result sorted by the order in which they appear on the first page. Based on my limited understanding of the database, I don't think the order of the links on a page are tracked. But just in case I'm wrong, can someone show me a query to do this? Or suggest an alternative approach? Thanks. Stefen Towers among the rest! Gab • Gruntwerk 23:49, 22 June 2024 (UTC)
- No, that's not possible; Quarry doesn't contain information about the content of the page.
- Could you give some additional information about what you want this for? There are several alternative approaches that would work, but I need to know a little more about what you want it for. BilledMammal (talk) 23:53, 22 June 2024 (UTC)
- I thought Quarry knows the links on a page, so that's where I was coming from. Anyway, I have a page that shows links sorted by popularity (views, descending) and another page that shows links to articles having old issues. I'd like an intersection of the links between them, in order of popularity (order of appearance on first page). Stefen Towers among the rest! Gab • Gruntwerk 00:03, 23 June 2024 (UTC)
- It can see which pages a given page links to (or is linked from), but doesn't have any information on what order it's done in - that would need the page content.Is this a one-time query, or will you need it repeated? —Cryptic 00:08, 23 June 2024 (UTC)
- I'd like for it to be repeatable as the underlying pages will change. I'm fine with having to run it manually. Stefen Towers among the rest! Gab • Gruntwerk 00:10, 23 June 2024 (UTC)
- (edit conflict) It does, but it doesn't have information beyond that, such as about the text of the page.
- I'm not aware of any tools that can help you with that, but I threw together the information you wanted using a quick and dirty script:
- It can see which pages a given page links to (or is linked from), but doesn't have any information on what order it's done in - that would need the page content.Is this a one-time query, or will you need it repeated? —Cryptic 00:08, 23 June 2024 (UTC)
- I thought Quarry knows the links on a page, so that's where I was coming from. Anyway, I have a page that shows links sorted by popularity (views, descending) and another page that shows links to articles having old issues. I'd like an intersection of the links between them, in order of popularity (order of appearance on first page). Stefen Towers among the rest! Gab • Gruntwerk 00:03, 23 June 2024 (UTC)
- BilledMammal (talk) 00:23, 23 June 2024 (UTC)
- I see you want something that can run repeatedly. I don't have time right now to put something together for you, but if Cryptic doesn't come up with something I'll do it sometime in the next couple of weeks - if I don't, feel free to remind me on my talk page. BilledMammal (talk) 00:24, 23 June 2024 (UTC)
- Thanks for the list - that's good for a start. Would you mind giving me a few clues on your approach for the script you did? It might snap me into figuring it out. Also, I have thought of using a spreadsheet or text compare software, but was hoping for an on-wiki or otherwise online approach. Stefen Towers among the rest! Gab • Gruntwerk 00:40, 23 June 2024 (UTC)
- A few Regex operations to get just the links in order, and then a basic python script that works down the first list and if the item exists on the second outputs it. Unfortunately, nothing online ATM. BilledMammal (talk) 00:49, 23 June 2024 (UTC)
- Thanks for the tips! Stefen Towers among the rest! Gab • Gruntwerk 00:50, 23 June 2024 (UTC)
- Any pure-sql-against-the-wmf-databases approach would have to start with something similar to either "Make a page in your userspace with redlinks to 1!Tom Cruise, 2!Muhammad Ali, ... 1000!Frank Torre" or "manually edit this stupidly long query that includes all that data" (like how quarry:query/81948 includes the namespace names, but with a thousand items instead of 30). —Cryptic 01:04, 23 June 2024 (UTC)
- Indeed, those don't seem like tenable approaches. But this discussion has helped me figure out a solution, not optimal but workable:
- Copy popular articles wikitext into a text editor, and break down into a flat list using a macro I constructed with regex and other tricks.
- Use PetScan to create a flat list of articles with old issues (this didn't have to be in any particular order).
- Insert both flat lists into their own column in a spreadsheet, then find matches of first column entries in the second column, then apply a filter of matches, and voila.
- Stefen Towers among the rest! Gab • Gruntwerk 04:18, 23 June 2024 (UTC)
- Indeed, those don't seem like tenable approaches. But this discussion has helped me figure out a solution, not optimal but workable:
- A few Regex operations to get just the links in order, and then a basic python script that works down the first list and if the item exists on the second outputs it. Unfortunately, nothing online ATM. BilledMammal (talk) 00:49, 23 June 2024 (UTC)
- BilledMammal (talk) 00:23, 23 June 2024 (UTC)