0
$\begingroup$

Such as I want to know the SE is change or not. This is my current method

StringLength[Import["https://mathematica.stackexchange.com/"]]

8320

But when you run it in another time

StringLength[Import["https://mathematica.stackexchange.com/"]]

8058

As you see,the result is not same,but actually the wesite is not change.. Is there any better method to avoid this problem?

$\endgroup$
  • 3
    $\begingroup$ I guess you'd have to define "changed" because it clearly has changed, only not it a way you are interested in. $\endgroup$ – Kuba Sep 10 '17 at 9:46
  • $\begingroup$ @Kuba Oh,good point,I mean.those content we can see directly have changed.such as some body have post a new question.Then I think it has been changed. $\endgroup$ – yode Sep 10 '17 at 10:05
  • $\begingroup$ Are you sure the difference isn't in all those "asked {time}", "modified {time}" ? $\endgroup$ – Kuba Sep 10 '17 at 10:17
  • 1
    $\begingroup$ There is also the solution to look at the modified header, but I would only use that on a static website. Not a dynamically generated one like StackExchange. $\endgroup$ – C. E. Sep 10 '17 at 12:59
  • 1
    $\begingroup$ @yode, if what you want is to monitor activity in mathematica.stackexchange.com the best option would be to use the Stack Exchange API and not to parse the website. Is that what you want? $\endgroup$ – rhermans Sep 10 '17 at 14:40
3
$\begingroup$

For instance:

active := 
  Module[{str, queslist, timelist, viewlist, votecount}, 
   str = Import[
     "https://mathematica.stackexchange.com/questions?sort=newest", 
     "XMLObject"];
   queslist = 
    Cases[str, 
     XMLElement[
       "h3", {}, {XMLElement[
         "a", {"shape" -> "rect", "class" -> "question-hyperlink", 
          "href" -> ___}, {ques___}]}] :> ques, Infinity];
   timelist = 
    Cases[str, 
     XMLElement[
       "span", {"class" -> "relativetime", 
        "title" -> ___}, {time___}] :> time, Infinity];
   viewlist = 
    Cases[str, 
     XMLElement[
       "div", {"class" -> "views", "title" -> view___}, ___] :> view, 
     Infinity];
   votecount = 
    Cases[str, 
     XMLElement[
       "span", {"class" -> "vote-count-post"}, {XMLElement[
         "strong", {}, {num___}]}] :> num, Infinity]; 
   Column[{"Mathematica Stackexchange ACTIVE", 
     TableForm[Transpose[{queslist, timelist, viewlist, votecount}], 
      TableHeadings -> {None, {"Question", "Time", "Views", 
         "Votes"}}]}, Alignment -> Center, Dividers -> All, 
    Background -> {{LightBlue, LightGreen}}]];
active

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.