Closed physicsnerd closed 6 years ago
Sounds like a good idea... We can create seporate program named secli
for this... I am not planning to expand socli to other stackexchange sites, since it is only intented to make stackoverflow search easier.
The main problem is that their are hundreds of stackexchange sites.... 😄
long post incoming :/
$ curl 'https://stackexchange.com/sites?view=list' | grep -P 'https://[a-z0-9]+.stackexchange.com' -o | uniq
https://webapps.stackexchange.com
https://gaming.stackexchange.com
https://webmasters.stackexchange.com
https://cooking.stackexchange.com
https://gamedev.stackexchange.com
https://photo.stackexchange.com
https://stats.stackexchange.com
https://math.stackexchange.com
https://diy.stackexchange.com
https://gis.stackexchange.com
https://tex.stackexchange.com
https://money.stackexchange.com
https://english.stackexchange.com
https://ux.stackexchange.com
https://unix.stackexchange.com
https://wordpress.stackexchange.com
https://cstheory.stackexchange.com
https://apple.stackexchange.com
https://rpg.stackexchange.com
https://bicycles.stackexchange.com
https://softwareengineering.stackexchange.com
https://electronics.stackexchange.com
https://android.stackexchange.com
https://boardgames.stackexchange.com
https://physics.stackexchange.com
https://homebrew.stackexchange.com
https://security.stackexchange.com
https://writers.stackexchange.com
https://video.stackexchange.com
https://graphicdesign.stackexchange.com
https://dba.stackexchange.com
https://scifi.stackexchange.com
https://codereview.stackexchange.com
https://codegolf.stackexchange.com
https://quant.stackexchange.com
https://pm.stackexchange.com
https://skeptics.stackexchange.com
https://fitness.stackexchange.com
https://drupal.stackexchange.com
https://mechanics.stackexchange.com
https://parenting.stackexchange.com
https://sharepoint.stackexchange.com
https://music.stackexchange.com
https://sqa.stackexchange.com
https://judaism.stackexchange.com
https://german.stackexchange.com
https://japanese.stackexchange.com
https://philosophy.stackexchange.com
https://gardening.stackexchange.com
https://travel.stackexchange.com
https://productivity.stackexchange.com
https://crypto.stackexchange.com
https://dsp.stackexchange.com
https://french.stackexchange.com
https://christianity.stackexchange.com
https://bitcoin.stackexchange.com
https://linguistics.stackexchange.com
https://hermeneutics.stackexchange.com
https://history.stackexchange.com
https://bricks.stackexchange.com
https://spanish.stackexchange.com
https://scicomp.stackexchange.com
https://movies.stackexchange.com
https://chinese.stackexchange.com
https://biology.stackexchange.com
https://poker.stackexchange.com
https://mathematica.stackexchange.com
https://cogsci.stackexchange.com
https://outdoors.stackexchange.com
https://martialarts.stackexchange.com
https://sports.stackexchange.com
https://academia.stackexchange.com
https://cs.stackexchange.com
https://workplace.stackexchange.com
https://windowsphone.stackexchange.com
https://chemistry.stackexchange.com
https://chess.stackexchange.com
https://raspberrypi.stackexchange.com
https://russian.stackexchange.com
https://islam.stackexchange.com
https://salesforce.stackexchange.com
https://patents.stackexchange.com
https://genealogy.stackexchange.com
https://robotics.stackexchange.com
https://expressionengine.stackexchange.com
https://politics.stackexchange.com
https://anime.stackexchange.com
https://magento.stackexchange.com
https://ell.stackexchange.com
https://sustainability.stackexchange.com
https://tridion.stackexchange.com
https://reverseengineering.stackexchange.com
https://networkengineering.stackexchange.com
https://opendata.stackexchange.com
https://freelancing.stackexchange.com
https://blender.stackexchange.com
https://space.stackexchange.com
https://sound.stackexchange.com
https://astronomy.stackexchange.com
https://tor.stackexchange.com
https://pets.stackexchange.com
https://ham.stackexchange.com
https://italian.stackexchange.com
https://aviation.stackexchange.com
https://ebooks.stackexchange.com
https://alcohol.stackexchange.com
https://softwarerecs.stackexchange.com
https://arduino.stackexchange.com
https://expatriates.stackexchange.com
https://matheducators.stackexchange.com
https://earthscience.stackexchange.com
https://joomla.stackexchange.com
https://datascience.stackexchange.com
https://puzzling.stackexchange.com
https://craftcms.stackexchange.com
https://buddhism.stackexchange.com
https://hinduism.stackexchange.com
https://communitybuilding.stackexchange.com
https://startups.stackexchange.com
https://worldbuilding.stackexchange.com
https://emacs.stackexchange.com
https://hsm.stackexchange.com
https://economics.stackexchange.com
https://lifehacks.stackexchange.com
https://engineering.stackexchange.com
https://coffee.stackexchange.com
https://vi.stackexchange.com
https://musicfans.stackexchange.com
https://woodworking.stackexchange.com
https://civicrm.stackexchange.com
https://health.stackexchange.com
https://rus.stackexchange.com
https://mythology.stackexchange.com
https://law.stackexchange.com
https://opensource.stackexchange.com
https://elementaryos.stackexchange.com
https://portuguese.stackexchange.com
https://computergraphics.stackexchange.com
https://hardwarerecs.stackexchange.com
https://3dprinting.stackexchange.com
https://ethereum.stackexchange.com
https://latin.stackexchange.com
https://languagelearning.stackexchange.com
https://retrocomputing.stackexchange.com
https://crafts.stackexchange.com
https://korean.stackexchange.com
https://monero.stackexchange.com
https://ai.stackexchange.com
https://esperanto.stackexchange.com
https://sitecore.stackexchange.com
https://iot.stackexchange.com
https://literature.stackexchange.com
https://vegetarianism.stackexchange.com
https://ukrainian.stackexchange.com
https://devops.stackexchange.com
https://bioinformatics.stackexchange.com
https://cseducators.stackexchange.com
https://meta.stackexchange.com
It seems making these vars dynamic will do the job.
Only socli.userpage
require to be 'refactored' nah ?
@arount yes... Just modifying the query vriable is required... are u sure that all the stackexchange sites use the same HTML classes on the code?
@gautamkrishnar Ho, I did not even think about it ^^. Did you want I make you a kind of poc about that ?
@gautamkrishnar, @arount - I'm pretty sure that classes are not the same between sites. For example, looking at the top nav bar alone on Stack Overflow, it uses classes like "navigation"; on other sites like Physics, it uses classes like "topbar-icon" and so on. Which classes need to be the same?
Looking at the question pages, their structure seems to be fairly similar, and the classes for the question content seem to be the same. Now that I think about it, the Stack Overflow nav bar was recently redesigned, so the different classes could be related to that and nothing else.
I'm working on a way to make the vars already specified dynamic - I think I have a decent solution that'll also allow for easy updating when new sites are added to the network; I'll let you know when it's finished.
I've got the solution now:
import re
siteslst = {}
with open('sites.txt', 'r') as s:
data = s.read()
data = data.splitlines()
for i in data:
keyVal = re.search(r'(\w+)\.',str(i)).group(1)
siteslst[str(keyVal)] = str(i)
testInput = siteslst.keys()
print('Sites: ', ', '.join(testInput), '\n')
validInput = False
while validInput == False:
searchSite = input("which site would you like to search? ")
if searchSite in testInput:
url = siteslst[searchSite]
urlSearch = siteslst[searchSite]+'/search?q='
validInput = True
else:
validInput = False
Along with a text file containing all the site links. Run it here to test it.
I forked socli already, but it's not at all up to date with recent commits and also has some code working on a separate issue. How do you want it to be added? Should I fork the repository again?
@physicsnerd We have a few developments going on the Develop branch. You can fork a fresh version if you want. Can you please wait till the next release so that we can manage this big change?.
@gautamkrishnar yep, I can wait until the next release - I'll keep an eye on that branch for it. Thanks for your help!
Lets keep this issue on hold for sometime. We have some pending feature implementations. Will reopen once ready.
Could this be expanded beyond Stack Overflow?