我正在尝试使用浏览器运行JavaScript文件。
通过这个例子你更容易理解我,我得到了以下代码:(jQuery)
var page = 1;
var data = [];
data.push($('#information').text());
page++;
location = 'www.example.com&page='+page;
我想从以下信息元素中获取文本:
www.example.com&page=1
www.example.com&page=2
www.example.com&page=3
..等等
是否可以使用镀铬扩展?用PHP试了一下,但该网站阻止了我在外面的尝试。
有什么想法吗?
答案 0 :(得分:0)
有两种方法可以做到这一点,具体取决于您尝试实现的目标。
答案 1 :(得分:0)
阅读你的问题后我有点困惑,因为这个问题有点不清楚。我想这就是你要找的东西。
class GameScene: SKScene {
var zombie = SKSpriteNode()
var spawnPoint1 = CGPointMake(1450, 311)
var spawnPoint2 = CGPointMake(1968, 406)
var spawnPoint3 = CGPointMake(1323, 470)
var mediumZombieMoveSpeed: CGFloat = 2
override func didMoveToView(view: SKView) {
for var b = 0; b < 5; b++ {
createZombie()
}
}
func createZombie() {
var randomModel = arc4random_uniform(4)
var randomPoint = arc4random_uniform(3)
if randomModel == 0 {
zombie = SKSpriteNode(texture: zombieTexM1)
if randomPoint == 0 {
zombie.position = spawnPoint1
}
else if randomPoint == 1 {
zombie.position = spawnPoint2
}
else {
zombie.position = spawnPoint3
}
zombie.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(32, 32))
zombie.physicsBody?.restitution = 0
zombie.physicsBody?.allowsRotation = false
zombie.name = "zombie"
world?.addChild(zombie)
}
else if randomModel == 1 {
zombie = SKSpriteNode(texture: zombieTexM2)
if randomPoint == 0 {
zombie.position = spawnPoint1
}
else if randomPoint == 1 {
zombie.position = spawnPoint2
}
else {
zombie.position = spawnPoint3
}
zombie.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(32, 32))
zombie.physicsBody?.restitution = 0
zombie.physicsBody?.allowsRotation = false
zombie.name = "zombie"
world?.addChild(zombie)
}
else if randomModel == 2 {
zombie = SKSpriteNode(texture: zombieTexM3)
if randomPoint == 0 {
zombie.position = spawnPoint1
}
else if randomPoint == 1 {
zombie.position = spawnPoint2
}
else {
zombie.position = spawnPoint3
}
zombie.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(32, 32))
zombie.physicsBody?.restitution = 0
zombie.physicsBody?.allowsRotation = false
zombie.name = "zombie"
world?.addChild(zombie)
}
else if randomModel == 3 {
zombie = SKSpriteNode(texture: zombieTexM4)
if randomPoint == 0 {
zombie.position = spawnPoint1
}
else if randomPoint == 1 {
zombie.position = spawnPoint2
}
else {
zombie.position = spawnPoint3
}
world?.addChild(zombie)
}
else {
zombie = SKSpriteNode(texture: zombieTexM5)
if randomPoint == 0 {
zombie.position = spawnPoint1
}
else if randomPoint == 1 {
zombie.position = spawnPoint2
}
else {
zombie.position = spawnPoint3
}
zombie.physicsBody = SKPhysicsBody(rectangleOfSize: CGSizeMake(32, 32))
zombie.physicsBody?.restitution = 0
zombie.physicsBody?.allowsRotation = false
world?.addChild(zombie)
}
}
}
答案 2 :(得分:0)
我想这就是你想要的。但是如果网站不支持CORS则要小心它不起作用
var page = 1, data = [];
getData();
function getData(){
if(page>=0){
$.get('http://websiteurl?page='+page,function(d){
d = $('<div/>').append(d);
data.push(d.find('#information').text());
page++;
getData();
}).fail(function(){
page = -1;
});
}
}