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

Hit count sample no longer works #36

Closed
rcook opened this issue Jan 28, 2016 · 8 comments
Closed

Hit count sample no longer works #36

rcook opened this issue Jan 28, 2016 · 8 comments

Comments

@rcook
Copy link
Contributor

rcook commented Jan 28, 2016

Unfortunately, the URL in the hit count example in README.md, i.e. http://www.haskell.org/haskellwiki/Haskell, returns a 302 "moved temporarily" HTTP response. I'll see if I can figure out a way to rewrite the sample to work.

Update: I tried changing the URL to https://wiki.haskell.org/Haskell. Unfortunately, the new front page no longer includes a hit count.

@ChristopherKing42
Copy link
Contributor

😢 I suppose we could place an issue here: https://github.com/haskell-infra/hl

@rcook
Copy link
Contributor Author

rcook commented Jan 28, 2016

I was thinking that a nice replacement example would be the Hackage page for this package: http://hackage.haskell.org/package/tagsoup. The example could extract the "Downloads" count from this page. I would rewrite the sample myself, but I haven't figured out how to use the package yet!

@erewok
Copy link

erewok commented Jan 28, 2016

You could just switch it to the last modified date at https://wiki.haskell.org/Haskell, which contains the same markup as it did before (I think):

<ul id="f-list">
  <li id="lastmod"> This page was last modified on 9 September 2013, at 22:38.</li>
  <li id="copyright">Recent content is available under <a href="/HaskellWiki:Copyrights" title="HaskellWiki:Copyrights">a simple permissive license</a>.</li>

Which make the example something like:

haskellHitCount = do
    src <- openURL "http://haskell.org/haskellwiki/Haskell"
    let modified = fromFooter $ parseTags src
    putStrLn modified
    where fromFooter = innerText . take 2 . dropWhile (~/= "<li id=lastmod>")

Alternately, to get the "Downloads" count you were looking for on the hackage page, something like the following should work, I think:

let table = dropWhile (~/= "<table class=properties>") $ parseTags src
let downloads = fromTagText . head . drop 1 . dropWhile (~/= "Downloads") $ filter isTagText table

@ChristopherKing42
Copy link
Contributor

👍 for Downloads count

@rcook
Copy link
Contributor Author

rcook commented Jan 30, 2016

I'll update the example to use last modified date for now. If I have time, I'll add an example that does download count too.

@ChristopherKing42
Copy link
Contributor

@rcook It appears that https://github.com/ndmitchell/tagsoup/blob/master/TagSoup/Sample.hs is where this would go.

@rcook
Copy link
Contributor Author

rcook commented Jan 30, 2016

@theking42 : Thanks!

ndmitchell added a commit that referenced this issue Jan 30, 2016
Fixes #36: Update first sample to extract last modified date from Haskell wiki
@ndmitchell
Copy link
Owner

Thanks @rcook and @theking42 for your patches and figuring out the problem and solution. I raised #40 to use Travis to run the demos, and hopefully catch such issues before users run into them.

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

No branches or pull requests

4 participants