Chrome inspect element content by code

时间:2017-04-09 23:38:51

标签: javascript html

I'm trying to write a code that reads through webpage source code and get data.

The webpage source code is kind of protected. I could get the data through Chrome inspect element, and copy the body as element and save as html file. Then I could get the data I want with no problem.

The only thing that I could not manage do to in code is how to get the inspect element content by code.

1 个答案:

答案 0 :(得分:1)

So.. i don't really understand what you mean but perhaps curl is what you are looking for?

something like:

curl https://en.wikipedia.org/wiki/Main_Page > test.html

will give you a file like:

<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title>Wikipedia, the free encyclopedia</title>
<script>document.documentElement.className...

Then you can do whatever you want to it. Hope this helps?

if you are using a machine which doesn't have curl: https://curl.haxx.se/

//with chocolatey
choco install curl

//with apt
apt install curl