Number of line in websiteURLFetch functionality for a Persian websiteLook up info associated with a given CAS chemical identifier from the NIST webbook & NCI CADD Chemical Identifier ResolverParse website data that requires interaction with a form (POST)How to crawl some website needed username and passwordImport file from website using process indiciatorImport the table from an html websiteHow to detect a website is changed or not?Can Mathematica run javascript on a website?Bing daily wallpaperScrape AJAX Website with Webdriver
What makes accurate emulation of old systems a difficult task?
Alignment of various blocks in tikz
Pre-plastic human skin alternative
Can we say “you can pay when the order gets ready”?
How to denote matrix elements succinctly?
How to have a sharp product image?
How exactly does Hawking radiation decrease the mass of black holes?
Is there a way to generate a list of distinct numbers such that no two subsets ever have an equal sum?
Could the terminal length of components like resistors be reduced?
How do I reattach a shelf to the wall when it ripped out of the wall?
How come there are so many candidates for the 2020 Democratic party presidential nomination?
Is the claim "Employers won't employ people with no 'social media presence'" realistic?
Why didn't the Space Shuttle bounce back into space as many times as possible so as to lose a lot of kinetic energy up there?
What are the steps to solving this definite integral?
Why must Chinese maps be obfuscated?
Was there a shared-world project before "Thieves World"?
Function pointer with named arguments?
bldc motor, esc and battery draw, nominal vs peak
Why did C use the -> operator instead of reusing the . operator?
Check if a string is entirely made of the same substring
What is causing the white spot to appear in some of my pictures
Can someone publish a story that happened to you?
Elements other than carbon that can form many different compounds by bonding to themselves?
How does Captain America channel this power?
Number of line in website
URLFetch functionality for a Persian websiteLook up info associated with a given CAS chemical identifier from the NIST webbook & NCI CADD Chemical Identifier ResolverParse website data that requires interaction with a form (POST)How to crawl some website needed username and passwordImport file from website using process indiciatorImport the table from an html websiteHow to detect a website is changed or not?Can Mathematica run javascript on a website?Bing daily wallpaperScrape AJAX Website with Webdriver
$begingroup$
I want to download the content of the website(contains text) and only a few lines from the content (from a specific number of the line up to the last line minus specific offset). Unfortunately, I do not know how to get the number of line in the content. For example, I want to replace 59 with the length of the content minus specific offset.
data1 = Import["https://en.wikipedia.org/wiki/Segment_tree"];
Snippet[data1, 51 ;; 59]
web-access
$endgroup$
add a comment |
$begingroup$
I want to download the content of the website(contains text) and only a few lines from the content (from a specific number of the line up to the last line minus specific offset). Unfortunately, I do not know how to get the number of line in the content. For example, I want to replace 59 with the length of the content minus specific offset.
data1 = Import["https://en.wikipedia.org/wiki/Segment_tree"];
Snippet[data1, 51 ;; 59]
web-access
$endgroup$
$begingroup$
You mean from line 51 to the end?Snippet[data1, 51 ;;]
.
$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
1
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
1
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07
add a comment |
$begingroup$
I want to download the content of the website(contains text) and only a few lines from the content (from a specific number of the line up to the last line minus specific offset). Unfortunately, I do not know how to get the number of line in the content. For example, I want to replace 59 with the length of the content minus specific offset.
data1 = Import["https://en.wikipedia.org/wiki/Segment_tree"];
Snippet[data1, 51 ;; 59]
web-access
$endgroup$
I want to download the content of the website(contains text) and only a few lines from the content (from a specific number of the line up to the last line minus specific offset). Unfortunately, I do not know how to get the number of line in the content. For example, I want to replace 59 with the length of the content minus specific offset.
data1 = Import["https://en.wikipedia.org/wiki/Segment_tree"];
Snippet[data1, 51 ;; 59]
web-access
web-access
edited Apr 23 at 12:32
Kiril Danilchenko
asked Apr 23 at 12:19
Kiril DanilchenkoKiril Danilchenko
8471416
8471416
$begingroup$
You mean from line 51 to the end?Snippet[data1, 51 ;;]
.
$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
1
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
1
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07
add a comment |
$begingroup$
You mean from line 51 to the end?Snippet[data1, 51 ;;]
.
$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
1
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
1
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07
$begingroup$
You mean from line 51 to the end?
Snippet[data1, 51 ;;]
.$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
You mean from line 51 to the end?
Snippet[data1, 51 ;;]
.$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
1
1
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
1
1
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07
add a comment |
2 Answers
2
active
oldest
votes
$begingroup$
One approach is to split the imported data on newlines using StringSplit
so the length of the resulting list is the line count. Then we can use Riffle
and StringJoin
to get the selected lines:
Module[start = 51, offset = 85, raw, data, linecount, stop,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
data = StringTrim@StringSplit[raw, "n"];
linecount = Length@data;
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
data = Take[data, start, stop];
Riffle[data, " "] // StringJoin]
Alternatively, we could count newlines in the raw data and use Snippet
as corey979 points out in the comments:
Module[start = 51, offset = 85, raw, linecount, stop, counter = 0,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
linecount = Block[str = StringToStream[raw],
While[Read[str, Record, NullRecords -> True] =!= EndOfFile,
counter++];
Close[str]; counter];
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
Snippet[raw, start ;; stop]]
The result for the website specified in the question gives:
This section describes the query operation of a segment tree in a
one-dimensional space. A query for a segment tree, receives a point q
x (should be one of the leaves of tree), and retrieves a list of all
the segments stored which contain the point q x . Formally stated;
given a node (subtree) v and a query point q x , the query can be
done using the following algorithm: Report all the intervals in I ( v
). If v is not a leaf: If q x is in Int(left child of v ) then
$endgroup$
add a comment |
$begingroup$
length = ToExpression[ToString[StringCount[#,"n"] & /@ FullForm[data1]]]+1
Snippet[data1,138;;length]
This page was last edited on 27 January 2019, at 05:26 (UTC) . Text
is available under the Creative Commons Attribution-ShareAlike
License ; additional terms may apply. By using this site, you agree
to the Terms of Use and Privacy Policy . Wikipedia® is a registered
trademark of the Wikimedia Foundation, Inc. , a non-profit
organization.
Privacy policy About Wikipedia Disclaimers Contact Wikipedia
Developers Cookie statement Mobile view
$endgroup$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195832%2fnumber-of-line-in-website%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
One approach is to split the imported data on newlines using StringSplit
so the length of the resulting list is the line count. Then we can use Riffle
and StringJoin
to get the selected lines:
Module[start = 51, offset = 85, raw, data, linecount, stop,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
data = StringTrim@StringSplit[raw, "n"];
linecount = Length@data;
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
data = Take[data, start, stop];
Riffle[data, " "] // StringJoin]
Alternatively, we could count newlines in the raw data and use Snippet
as corey979 points out in the comments:
Module[start = 51, offset = 85, raw, linecount, stop, counter = 0,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
linecount = Block[str = StringToStream[raw],
While[Read[str, Record, NullRecords -> True] =!= EndOfFile,
counter++];
Close[str]; counter];
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
Snippet[raw, start ;; stop]]
The result for the website specified in the question gives:
This section describes the query operation of a segment tree in a
one-dimensional space. A query for a segment tree, receives a point q
x (should be one of the leaves of tree), and retrieves a list of all
the segments stored which contain the point q x . Formally stated;
given a node (subtree) v and a query point q x , the query can be
done using the following algorithm: Report all the intervals in I ( v
). If v is not a leaf: If q x is in Int(left child of v ) then
$endgroup$
add a comment |
$begingroup$
One approach is to split the imported data on newlines using StringSplit
so the length of the resulting list is the line count. Then we can use Riffle
and StringJoin
to get the selected lines:
Module[start = 51, offset = 85, raw, data, linecount, stop,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
data = StringTrim@StringSplit[raw, "n"];
linecount = Length@data;
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
data = Take[data, start, stop];
Riffle[data, " "] // StringJoin]
Alternatively, we could count newlines in the raw data and use Snippet
as corey979 points out in the comments:
Module[start = 51, offset = 85, raw, linecount, stop, counter = 0,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
linecount = Block[str = StringToStream[raw],
While[Read[str, Record, NullRecords -> True] =!= EndOfFile,
counter++];
Close[str]; counter];
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
Snippet[raw, start ;; stop]]
The result for the website specified in the question gives:
This section describes the query operation of a segment tree in a
one-dimensional space. A query for a segment tree, receives a point q
x (should be one of the leaves of tree), and retrieves a list of all
the segments stored which contain the point q x . Formally stated;
given a node (subtree) v and a query point q x , the query can be
done using the following algorithm: Report all the intervals in I ( v
). If v is not a leaf: If q x is in Int(left child of v ) then
$endgroup$
add a comment |
$begingroup$
One approach is to split the imported data on newlines using StringSplit
so the length of the resulting list is the line count. Then we can use Riffle
and StringJoin
to get the selected lines:
Module[start = 51, offset = 85, raw, data, linecount, stop,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
data = StringTrim@StringSplit[raw, "n"];
linecount = Length@data;
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
data = Take[data, start, stop];
Riffle[data, " "] // StringJoin]
Alternatively, we could count newlines in the raw data and use Snippet
as corey979 points out in the comments:
Module[start = 51, offset = 85, raw, linecount, stop, counter = 0,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
linecount = Block[str = StringToStream[raw],
While[Read[str, Record, NullRecords -> True] =!= EndOfFile,
counter++];
Close[str]; counter];
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
Snippet[raw, start ;; stop]]
The result for the website specified in the question gives:
This section describes the query operation of a segment tree in a
one-dimensional space. A query for a segment tree, receives a point q
x (should be one of the leaves of tree), and retrieves a list of all
the segments stored which contain the point q x . Formally stated;
given a node (subtree) v and a query point q x , the query can be
done using the following algorithm: Report all the intervals in I ( v
). If v is not a leaf: If q x is in Int(left child of v ) then
$endgroup$
One approach is to split the imported data on newlines using StringSplit
so the length of the resulting list is the line count. Then we can use Riffle
and StringJoin
to get the selected lines:
Module[start = 51, offset = 85, raw, data, linecount, stop,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
data = StringTrim@StringSplit[raw, "n"];
linecount = Length@data;
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
data = Take[data, start, stop];
Riffle[data, " "] // StringJoin]
Alternatively, we could count newlines in the raw data and use Snippet
as corey979 points out in the comments:
Module[start = 51, offset = 85, raw, linecount, stop, counter = 0,
raw = Import["https://en.wikipedia.org/wiki/Segment_tree"];
linecount = Block[str = StringToStream[raw],
While[Read[str, Record, NullRecords -> True] =!= EndOfFile,
counter++];
Close[str]; counter];
stop = linecount - offset;
Print["# lines: ", linecount];
Print[" start: ", start];
Print[" stop: ", stop];
Print["# saved: ", stop - start];
Snippet[raw, start ;; stop]]
The result for the website specified in the question gives:
This section describes the query operation of a segment tree in a
one-dimensional space. A query for a segment tree, receives a point q
x (should be one of the leaves of tree), and retrieves a list of all
the segments stored which contain the point q x . Formally stated;
given a node (subtree) v and a query point q x , the query can be
done using the following algorithm: Report all the intervals in I ( v
). If v is not a leaf: If q x is in Int(left child of v ) then
edited Apr 23 at 15:55
answered Apr 23 at 13:39
dionysdionys
2,95511235
2,95511235
add a comment |
add a comment |
$begingroup$
length = ToExpression[ToString[StringCount[#,"n"] & /@ FullForm[data1]]]+1
Snippet[data1,138;;length]
This page was last edited on 27 January 2019, at 05:26 (UTC) . Text
is available under the Creative Commons Attribution-ShareAlike
License ; additional terms may apply. By using this site, you agree
to the Terms of Use and Privacy Policy . Wikipedia® is a registered
trademark of the Wikimedia Foundation, Inc. , a non-profit
organization.
Privacy policy About Wikipedia Disclaimers Contact Wikipedia
Developers Cookie statement Mobile view
$endgroup$
add a comment |
$begingroup$
length = ToExpression[ToString[StringCount[#,"n"] & /@ FullForm[data1]]]+1
Snippet[data1,138;;length]
This page was last edited on 27 January 2019, at 05:26 (UTC) . Text
is available under the Creative Commons Attribution-ShareAlike
License ; additional terms may apply. By using this site, you agree
to the Terms of Use and Privacy Policy . Wikipedia® is a registered
trademark of the Wikimedia Foundation, Inc. , a non-profit
organization.
Privacy policy About Wikipedia Disclaimers Contact Wikipedia
Developers Cookie statement Mobile view
$endgroup$
add a comment |
$begingroup$
length = ToExpression[ToString[StringCount[#,"n"] & /@ FullForm[data1]]]+1
Snippet[data1,138;;length]
This page was last edited on 27 January 2019, at 05:26 (UTC) . Text
is available under the Creative Commons Attribution-ShareAlike
License ; additional terms may apply. By using this site, you agree
to the Terms of Use and Privacy Policy . Wikipedia® is a registered
trademark of the Wikimedia Foundation, Inc. , a non-profit
organization.
Privacy policy About Wikipedia Disclaimers Contact Wikipedia
Developers Cookie statement Mobile view
$endgroup$
length = ToExpression[ToString[StringCount[#,"n"] & /@ FullForm[data1]]]+1
Snippet[data1,138;;length]
This page was last edited on 27 January 2019, at 05:26 (UTC) . Text
is available under the Creative Commons Attribution-ShareAlike
License ; additional terms may apply. By using this site, you agree
to the Terms of Use and Privacy Policy . Wikipedia® is a registered
trademark of the Wikimedia Foundation, Inc. , a non-profit
organization.
Privacy policy About Wikipedia Disclaimers Contact Wikipedia
Developers Cookie statement Mobile view
edited Apr 23 at 14:30
answered Apr 23 at 13:47
amator2357amator2357
4488
4488
add a comment |
add a comment |
Thanks for contributing an answer to Mathematica Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
Use MathJax to format equations. MathJax reference.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195832%2fnumber-of-line-in-website%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
$begingroup$
You mean from line 51 to the end?
Snippet[data1, 51 ;;]
.$endgroup$
– corey979
Apr 23 at 12:26
$begingroup$
@corey979 I edit the question to be more specific
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:33
1
$begingroup$
Snippet[data1, 51 ;; -17]
$endgroup$
– corey979
Apr 23 at 12:38
$begingroup$
@corey979 thank you for the answer,but if I'm interested to know the length of the content. How I can get it?
$endgroup$
– Kiril Danilchenko
Apr 23 at 12:46
1
$begingroup$
So you want to know the length of the content, not take its snippet from a given line to the end, or to some numbered line from the end? So that's quite different than you have in the question: "replace 59 with the length of the content minus specific offset" would give the same outputs as my codes above.
$endgroup$
– corey979
Apr 23 at 14:07